Last active
June 30, 2020 06:30
-
-
Save chexton/6160663 to your computer and use it in GitHub Desktop.
abandoned-cart.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 = 'customer@domain.com'; // 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