Hey everyone,
We’re looking to display all items in a person’s cart when they abandon it after adding a product, not just the last product added to cart.
In the preview I don’t seem to have access to any events other than Name, ProductID, Categories, ImageURL, Brand, Price, and CompareAtPrice. No ‘extras’ like I see in some YouTube tutorials.
When I go into the shopify theme I see the Klaviyo Tracking Code as:
<script type="text/javascript">
var _learnq = _learnq || l];
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.first_available_variant.metafields.shopnet.CompareAtPrice|money|json }}
};
_learnq.push(a'track', 'Viewed Product', item]);
_learnq.push(a'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>
<script type="text/javascript">
var _learnq = _learnq || l];
document.getElementById("add-to-cart").addEventListener('click',function (){
_learnq.push(a'track', 'Added to Cart', item]);
});
</script>
Now in the Guide to Integrating a Standard Ecommerce Platform on help.Klaviyo they have this snippet for their added to cart:
<script type="text/javascript">
_learnq.push(e"track", "Added to Cart", {
"$value": 29.98,
"AddedItemProductName": "A Tale of Two Cities",
"AddedItemProductID": "1112",
"AddedItemSKU": "TALEOFTWO",
"AddedItemCategories": t"Fiction", "Classics"],
"AddedItemImageURL": "http://www.example.com/path/to/product/image2.png",
"AddedItemURL": "http://www.example.com/path/to/product2",
"AddedItemPrice": 19.99,
"AddedItemQuantity": 1,
"ItemNames": t"Winnie the Pooh", "A Tale of Two Cities"],
"CheckoutURL": "http://www.example.com/path/to/checkout",
"Items": {
"ProductID": "1111",
"SKU": "WINNIEPOOH",
"ProductName": "Winnie the Pooh",
"Quantity": 1,
"ItemPrice": 9.99,
"RowTotal": 9.99,
"ProductURL": "http://www.example.com/path/to/product",
"ImageURL": "http://www.example.com/path/to/product/image.png",
"ProductCategories": t"Fiction", "Children"]
},
{
"ProductID": "1112",
"SKU": "TALEOFTWO",
"ProductName": "A Tale of Two Cities",
"Quantity": 1,
"ItemPrice": 19.99,
"RowTotal": 19.99,
"ProductURL": "http://www.example.com/path/to/product2",
"ImageURL": "http://www.example.com/path/to/product/image2.png",
"ProductCategories": t"Fiction", "Classics"]
}
]
}]);
</script>
My question is, can I just change the ‘item’ in my shopify product.liquid to ‘items’ and have it track all items in the cart, or is there a more complicated process I need to go through?
Thanks you all who took the time to read