Create a Custom "Add to Cart" Event for Shopify

read

Klaviyo tracks a Checkout Started event from Shopify when a shopper enters their email address and shipping information ("Customer information") on the first page of the Shopify checkout process and clicks continue ("Continue to delivery method"). This metric is included in the Klaviyo/Shopify integration and does not require any additional work to set up.

If you would like to track an event as soon as a shopper adds an item to their cart, you can do this by adding a line of Javascript to your Shopify store's product.liquid theme file.

Please note that you must already have Viewed Product tracking installed in order for the Add to Cart event to function properly. You can paste the code (shown below) underneath the Viewed Product code in your product.liquid theme.

<script text="text/javascript">
	document.getElementById("AddToCart-product-template").addEventListener('click',function (){
 _learnq.push(['track', 'Add To Cart', item]);
 }); 
 </script>

This event functions similarly to the Viewed Product event in that each item someone adds to their cart will trigger a new event. So, if you build a flow triggered by the Add to Cart event, make sure to add a condition to the flow that will prevent shoppers from being bombarded with emails each time they add an item to their cart.

2017-09-01_13-42-52.png

Was this article helpful?
1 out of 1 found this helpful