This script needs to be fired every time a user is adding, updating or deleting a product from the cart. It needs to contain all products found in the cart, even the products not updated by the current "Add to cart" click. You can add multiple items by adding multiple addEcommerceItem functions. Again, the variables ({{name}}, {{sku}}, etc.) mentioned below need to be dynamically filled with the data of the item.

<script type="text/javascript">
_paq.push(['addEcommerceItem',
"{{sku}}",
"{{name}}",
"{{categoryname}}",
{{price}},
{{quantity}}
]);


// Here it is important to add all other products found in the cart, even the products not updated by the current "Add to cart" click


_paq.push(['trackEcommerceCartUpdate',
{{totalcartvalue}}
]);
_paq.push(['trackPageView']);
</script>

Shopping cart script example with two products

<script>
_paq.push(['addEcommerceItem',
"9780786706211",
"Endurance: Shackleton's Incredible Voyage",
["Adventure Books", "Best sellers"],
8.8,
2
]);
_paq.push(['addEcommerceItem',
"7659837658343",
"Nike Shoe",
"Shoes",
70,
1
]);
_paq.push(['trackEcommerceCartUpdate',
87.6
]);
_paq.push(['trackPageView']);
</script>

Validation:
https://help.datatrics.com/en/articles/3195126-check-if-the-shopping-cart-script-is-implemented-correctly

Did this answer your question?