Skip to content

Instantly share code, notes, and snippets.

@parkerproject
Forked from chexton/abandoned-cart.js
Created February 19, 2020 12:53
Show Gist options
  • Save parkerproject/5d806890c581905542a9c2c09f0fec60 to your computer and use it in GitHub Desktop.
Save parkerproject/5d806890c581905542a9c2c09f0fec60 to your computer and use it in GitHub Desktop.
abandoned-cart.js
//1. Grab the first snippet
<script type="text/javascript">
var _veroq = _veroq || [];
_veroq.push(['init', { api_key: 'ce8e305b4c762721725194840ec18fda4f97febd'} ]);
(function() {var ve = document.createElement('script'); ve.type = 'text/javascript'; ve.async = true; ve.src = '//getvero.com/assets/m.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ve, s);})();
</script>
//2. Put this on the begins checkout OR cart page (depending where you first collect the customer's email)
<script type="text/javascript">
// Get the customer's email and drop the Vero cookie (add them to the database)
var email = '[email protected]'; // Update this dynamically
_veroq.push(['user', {id: email, email: email}]);
// Cycle through each product in the cart
var products = [];
for(var i=0;i<products_purchased.length;i++)) { // Cycle through each item they purchased. Here I use a Javascript loop, you could use whatever works!
var product_details = {name: 'product name', url: 'product url', image_url: 'product image url'};
products.push(product_details);
}
// Track an event with the products in their cart
_veroq.push(['track', 'begins checkout', {products: products}]);
</script>
//3. Track those customers that DO complete checkout
<script type="text/javascript">
_veroq.push(['track', 'completes checkout']);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment