Skip to content

Instantly share code, notes, and snippets.

View elephantsneverforget's full-sized avatar

Jonathan Cairo elephantsneverforget

View GitHub Profile
@elephantsneverforget
elephantsneverforget / klaviyo_atc_payload.js
Created February 1, 2024 14:34
Klaviyo Payload Sample - Email/SMS marketing
{
"textPayload": "Domain: danas-3-13-new-install.myshopify.com Sending Event to Klaviyo (obfuscated)",
"data": {
"type": "event",
"attributes": {
"value": 629.95,
"unique_id": "8c70b10f-e859-4e51-81f4-707c9af99339",
"profile": {
"$email": "bc17df29a4c0d90d70abe7c07d081b3049e1c5a6b4638eba0c6c8e7a888c62b8",
"$first_name": "2c9e0a2585dc7406589a3724f0027811506e0f133726303a15d6779d532a2573",
type PostscriptEventPayload = {
type: string; // event name
phone?: string;
email?: string;
external_id: string; // event id
// Because Postscript doesn't allow nested properties (yet) we have been advised by Postscript to keep the payload simple.
properties: {
preEventCartTotal?: number;
preEventCartItemCount?: number;
currency?: string;
#!/usr/bin/env python
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
// Lucky Labs creates a Custom Event with additional data
var luckyEvent = new CustomEvent('luckyEvent',
{
detail:
{
message: 'store_finder_event',
email: "[email protected]",
location: "",
otherInfo: "",
product: {}
export type PostscriptEventPayload = {
type: string; // event name
phone?: string;
email?: string;
external_id: string; // event id
// Because Postscript doesn't allow nested properties (yet) we have been advised by Postscript to keep the payload simple.
properties: {
preEventCartTotal?: number;
preEventCartItemCount?: number;
currency?: string;
<script defer src="https://cdn.jsdelivr.net/gh/elephantsneverforget/gtm_block_detect@main/gtm_block_detect_d.js"></script>
window.ElevarDataLayer.push({
event: "dl_subscribe",
lead_type: "...", // should be "email" or "phone"
user_properties: {
customer_email: "...", // required if lead type is "email"
customer_phone: "..." // required if lead type is "phone"
}
});

Tracked Events

  • page view
  • view item
  • view item list
  • select item
  • add to cart
  • remove from cart
  • login
  • sign up
  • view cart
const injectScript = require('injectScript');
const encodeUriComponent = require('encodeUriComponent');
const queryPermission = require('queryPermission');
const setDefaultConsentState =require('setDefaultConsentState');
const getCookieValues = require("getCookieValues");
const logToConsole = require("logToConsole");
const isConsentGranted = require('isConsentGranted');
const updateConsentState = require("updateConsentState");
const getContainerVersion = require('getContainerVersion');
const addConsentListener = require('addConsentListener');
@elephantsneverforget
elephantsneverforget / web_pixel.js
Created September 25, 2023 17:56
Gets discount information in the Web Pixel
getTotalShippingDiscount: function (event) {
const discountApplications = event?.data?.checkout?.discountApplications || [];
const shippingDiscountApplications = discountApplications.filter(
(discountApplication) => discountApplication?.targetType === "SHIPPING_LINE"
);
const shippingDiscountApplicationsPercentBased =
shippingDiscountApplications.filter(
(discountApplication) =>
typeof discountApplication?.value?.percentage !== "undefined"