Question

Showing all items in the cart for Abandoned Cart Reminder flow

  • 4 June 2021
  • 1 reply
  • 55 views

Badge

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 || [];

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(['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>

<script type="text/javascript">
var _learnq = _learnq || [];
document.getElementById("add-to-cart").addEventListener('click',function (){
_learnq.push(['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(["track", "Added to Cart", {
"$value": 29.98,
"AddedItemProductName": "A Tale of Two Cities",
"AddedItemProductID": "1112",
"AddedItemSKU": "TALEOFTWO",
"AddedItemCategories": ["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": ["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": ["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": ["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


1 reply

Userlevel 5
Badge +4

Hi @PinkErik,

 

I hope you are having a nice weekend!

 

We will only ever show one product in the “Added to Cart” event triggered flow because the triggering action is only associated with adding one product to the cart (the triggering action being clicking the button “add to cart” for a product).

 

If you would like to display all items in the cart, my recommendation would be to also set up a “Started Checkout” triggered abandoned cart flow. This flow will display all items in a user’s cart once they abandon checkout. 

 

If you choose to have both “Added to Cart” and “Started Checkout” triggered flows live and running, I’d recommend adding the flow filter to your added to cart event trigged flow, started checkout zero times since starting this flow” and “placed order zero times since starting this flow.” This will ensure that you do not trigger both the added to cart and started checkout flows.

 

Best,

Julie

Reply