Skip to content

Instantly share code, notes, and snippets.

@elephantsneverforget
Created September 11, 2023 16:56
Show Gist options
  • Save elephantsneverforget/fcd1dc704a4213ea28e6943dfbe04545 to your computer and use it in GitHub Desktop.
Save elephantsneverforget/fcd1dc704a4213ea28e6943dfbe04545 to your computer and use it in GitHub Desktop.
/** Collection/Search page product click...
this is the product the user clicks on from collection page **/
window.ElevarPushToDataLayer({
event: "dl_select_item",
ecommerce: {
currencyCode: "USD",
click: {
actionField: {
list: location.pathname, // this should be the collection page URL
action: "click"
},
products: [{
id: "LB00161-34689553170476", // SKU
name: "Lovebox Original Color & Photo", // Product title
brand: "Lovebox INC",
category: "Home,Living,Art & Objects,Tabletop",
variant: "USA wall plug",
price: "119.99",
quantity: "1", // Not required for dl_select_item & dl_view_item
position: item.position, // Only required for dl_select_item; position in the list of search results, collection views and position in cart indexed starting at 1
list: "/art/wallhangings", // The list the product was discovered from
product_id: "6979886940352", // The product_id
variant_id: "41141193965760", // id or variant_id
compare_at_price: "139.99", // If available on dl_view_item & dl_add_to_cart otherwise use "0.0"
image: "//cdn.shopify.com/small.png", // If available, otherwise use an empty string
inventory: "5" // If available, only required on dl_view_item
},
...
]
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment