Skip to content

Instantly share code, notes, and snippets.

@vevgeniy85
Last active December 29, 2021 12:58
Show Gist options
  • Save vevgeniy85/22ef5c198d4003ac8b2ded04789e8e73 to your computer and use it in GitHub Desktop.
Save vevgeniy85/22ef5c198d4003ac8b2ded04789e8e73 to your computer and use it in GitHub Desktop.
Add new snippet klaviyo-tracking.liquid, paste code and include snippet {% include 'klaviyo-tracking' %} to product.liquid template
<script type="text/javascript">
var _learnq = _learnq || [];
var item = {
Name: {{ product.title|json }},
ProductID: {{ product.id|json }},
Categories: {{ product.collections|map:'title'|json }},
ImageURL: "https:{{ product.featured_image.src|img_url:'grande' }}",
URL: "{{ shop.secure_url }}{{ product.url }}",
Brand: {{ product.vendor|json }},
Price: {{ product.price|money|json }},
CompareAtPrice: {{ product.compare_at_price_max|money|json }}
};
_learnq.push(['track', 'Viewed Product', item]);
_learnq.push(['trackViewedItem', {
Title: item.Name,
ItemId: item.ProductID,
Categories: item.Categories,
ImageUrl: item.ImageURL,
Url: item.URL,
Metadata: {
Brand: item.Brand,
Price: item.Price,
CompareAtPrice: item.CompareAtPrice
}
}]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment