Skip to content

Instantly share code, notes, and snippets.

View elephantsneverforget's full-sized avatar

Jonathan Cairo elephantsneverforget

View GitHub Profile
@elephantsneverforget
elephantsneverforget / cart_contents.js
Last active July 27, 2023 13:24
Available data for add to cart Klaviyo events
{
brand: "SACHEU Beauty"
category: "face serum > gua sha oil > face oil > face massage oil > face roller oil > gua sha serum > thick skin > thick skin serum > facial serum"
id: "SA-TS-ESS-LIP-1"
image: "https://cdn.shopify.com/s/files/1/0257/7583/3137/products/sacheu-beauty-face-serum-gua-sha-oil-face-oil-face-massage-oil-face-roller-oil-gua-sha-serum-thick-skin-thick-skin-serum-facial-serum-slick-skin-gua-sha-serum-28666524074033.jpg?v=1656436052"
list: ""
name: "SLICK SKIN - GUA SHA SERUM"
price: "25.60"
product_id: "4818754666545"
quantity: "1"
// Event: Page View
// URL
// Zulily.com/track/pageview
// Payload
{
"name": "PAGEVIEW",
"pagetype": "home",
etc...
const hash = async (str) => {
return [
...new Uint8Array(
await crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode(str)
)
)
].map(b => b.toString(16).padStart(2, "0")).join("")
}
{
"token": "1bee3c84eef8e43800c5d4ac2adaec94",
"note": null,
"attributes": {
"_elevar__fbp": "fb.1.1689171902384.1162845275",
"_elevar__ga": "GA1.1.6d9d59fe-cb67-43a1-95ce-b1756390d71b",
"_elevar__ga_9P8MDN9F41": "GS1.1.1689171901.1",
"_elevar__ga_W908C3LLGQ": "GS1.1.1689171901.1",
"_elevar_visitor_info": "{\"user_id\":\"6d9d59fe-cb67-43a1-95ce-b1756390d71b\",\"session_id\":\"1689171901\",\"session_count\":\"21\",\"referrer\":\"https://www.google.com/\",\"OutbrainClickID\":\"test\"}"
},
import { type KlaviyoEventsConnectorConfig } from "elevar-common-ts/src/apiTypes";
import { type ChannelContext } from "../subscriber/context/types";
import { type ConfigToStandardEvent } from "./message";
/* ========================================================================== */
// https://developers.klaviyo.com/en/reference/create_event
export type KlaviyoEventPayload = {
data: {
// How we listen for events
window.addEventListener("emailSubmittedEvent", event => {
if (event.detail.lead_type === "email") {
push({ email: event.detail.email });
}
if (event.detail.lead_type === "phone") {
push({ phone: event.detail.phone });
}
});
Invalid request: {'data': [{'event_time': 1685858347, 'event_name': 'view_category', 'event_id': '2e6a02c8-24b9-4a8f-a0e3-301295efd503', 'action_source': 'web', 'event_source_url': 'https://www.hunterfan.com/collections/ceiling-fans?filter.p.m.ProductTag.Multi_Exclusive_Technology=SureSpeed+Guarantee&filter.p.m.ProductTag.Fan_Size=52+inch&filter.p.m.ProductTag.Housing_color_Multi=White&filter.p.m.ProductTag.Type=Indoor&sort_by=manual', 'user_data': {'external_id': ['c3b451ea196d0ad5556e3f9c7dee5929ffe458769eb30bb33d52856f9e9464d8'], 'country': ['79adb2a2fce5c6ba215fe5f27f532d4e7edbac4b6a5e09e1ef3a08084a904621'], 'ct': ['8ee68da841902b2c811b8c7dbe72efcce7ee287feeab966f680a2428a34d57bd'], 'st': ['193d984cc43c234ce581f221496f1965ff3be1a7f416f8ea6ed83e7b96a132a2'], 'zp': ['9c71a8438524c134eac7c88fb0337a0544d89280fb54219eab6b6919352a5d61'], 'client_ip_address': '104.6.103.130', 'client_user_agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/
// Include the required APIs
const log = require('logToConsole');
const sendPixel = require('sendPixel');
const encodeUriComponent = require('encodeUriComponent');
const copyFromDataLayer = require('copyFromDataLayer');
const localStorage = require('localStorage');
const queryPermission = require('queryPermission');
const getCookieValues = require('getCookieValues');
const localStorageID = 'partnerizeClickReference';
type LineItemKey =
| `ItemCategory${number}`
| `ItemSku${number}`
| `ItemSubTotal${number}`
| `ItemQuantity${number}`
| `ItemName${number}`;
export type ImpactRadiusLineItems = {
[key in LineItemKey]: number | string;
};
<script type="text/javascript">
var _learnq = _learnq || [];
var item = {
"ProductName": "{{dlv - Product View - Name}}",
"ProductID": "{{dlv - Product View - Product ID}}",
"ImageURL": "https:{{dlv - Product View - Image}}",
"URL": "https://{{Page Hostname}}{{Page Path}}",
"Brand": "{{dlv - Product View - Brand}}",
"Price": {{dlv - Product View - Price}},
"CompareAtPrice": {{dlv - Product View - Compare At Price}}