Skip to content

Instantly share code, notes, and snippets.

@elephantsneverforget
Created March 27, 2023 21:04
Show Gist options
  • Save elephantsneverforget/da66ae71e9211c307a7a6d9585bff120 to your computer and use it in GitHub Desktop.
Save elephantsneverforget/da66ae71e9211c307a7a6d9585bff120 to your computer and use it in GitHub Desktop.
export type KlaviyoEventPayload = {
data: {
type: "event";
attributes: {
time: string; // "2022-11-08T00:00:00"
value: number;
unique_id: string; // event_id
profile: {
// One of email or phone is required on every API call
$email: string;
$phone_number?: string;
$first_name?: string;
$last_name?: string;
$city?: string;
$region?: string;
$country?: string;
$zip?: string;
$image?: string;
$consent?: string;
};
metric: {
name: KlaviyoDLEventName;
};
properties: {
// Where event data goes. Top level items are segmentable in platform so data needs to show twice here
// See bottom of https://help.klaviyo.com/hc/en-us/articles/115005062847
itemNames: Array<string>;
productIds: Array<string>;
variantIds: Array<string>;
prices: Array<number>;
// skus: Array<string>; // not sending sku since not all products have this and could throw off segments if some have and some don't
categories?: Array<string>;
imageURLs?: Array<string>;
brands?: Array<string>;
compareAtPrices?: Array<number>;
items?: Array<KlaviyoItem>;
};
};
};
};
type KlaviyoItem = {
name: string;
productId: string;
variantId: string;
price: number;
sku?: string; // not sending sku because not all products have this and could affect reporting
quantity?: number;
imageURL?: string;
category?: string;
brand?: string;
productURL?: string;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment