install-vero-ecommerce.js
//--
// 1. Install the Vero library
//--
<script type="text/javascript">
var _veroq = _veroq || [];
_veroq.push(['init', { api_key: 'YOUR_API_KEY' } ]); // Replace with your API key from https://app.getvero.com/account
(function() {var ve = document.createElement('script'); ve.type = 'text/javascript'; ve.async = true; ve.src = '//d3qxef4rp70elm.cloudfront.net/m.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ve, s);})();
</script>
//--
// 2. Track when someone signs up or is logged in.
//--
// You put this just before </head>
// On any page where you get a customer's email (after sign up, sign in and on subscribe confirmation pages)
// you need to replace the email variable.
<script>
var email = "CUSTOMER_EMAIL"; // Replace with customer's email
_veroq.push(['user', {
id: email,
email: email
}]);
</script>
//--
// 3. Track when someone views a product
//--
// Replace appropriate attributes with product-specific values
<script>
_veroq.push(['track', 'viewed product', {
sku: 'product-sku',
name: 'product-name',
price: 'product-price',
url: 'product-url',
image_url: 'product-image-url'
}]);
</script>
//--
// 4. Track when someone views their cart
//--
// Replace appropriate attributes with cart-specific values
<script>
var products = [];
for (i=0;i<LENGTH;i++){ // Cycle thorugh each product in cart and add to array, ou don't HAVE to use JS, just output JS code
products.push({
sku: 'product-sku',
name: 'product-name',
price: 'product-price',
url: 'product-url',
image_url: 'product-image-url'
} );
}
_veroq.push(['track', 'views cart', {
products: products
}]);
</script>
//--
// 5. Track when someone begins checkout
//--
// Replace appropriate attributes with cart-specific values
<script>
var products = [];
for (i=0;i<LENGTH;i++){ // Cycle thorugh each product in cart and add to array, ou don't HAVE to use JS, just output JS code
products.push({
sku: 'product-sku',
name: 'product-name',
price: 'product-price',
url: 'product-url',
image_url: 'product-image-url'
} );
}
_veroq.push(['track', 'begins checkout', {
products: products
}]);
</script>
//--
// 6. Track when someone completes checkout
//--
// Replace appropriate attributes with cart-specific values
<script>
var products = [];
for (i=0;i<LENGTH;i++){ // Cycle thorugh each product in cart and add to array, ou don't HAVE to use JS, just output JS code
products.push({
sku: 'product-sku',
name: 'product-name',
price: 'product-price',
url: 'product-url',
image_url: 'product-image-url'
} );
}
_veroq.push(['track', 'completes checkout', {
products: products
}]);
</script>
// You should also check out our docs for direct API requests: https://www.getvero.com/docs
// and API docs: https://www.getvero.com/api/javascript
// Questions: support@getvero.com