chexton
8/11/2013 - 6:09 AM

magento-and-vero.js

magento-and-vero.js

//Some of these snippets of code should be surrounded by <script></script>. They have been removed for brevity.
 
//1. Place this code on every page the customer is logged in, in the head.phtml file.
<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) { $email = Mage::getSingleton('customer/session')->getCustomer()->getEmail(); ?>
    _veroq.push(['user', {id: '<?php echo $email; ?>', email: '<?php echo $email; ?>', }]);
    
    // You need to get the unsubscribe status of a user from your DB. This will handle unsubscribes site-wide
    <?php if(UNSUBSCRIBED) { ?>
        _veroq.push(['tags', {id: '<?php echo $email; ?>', add: ['unsubscribed']}]);
    <?php } else { ?>
        _veroq.push(['tags', {id: '<?php echo $email; ?>', remove: ['unsubscribed']}]);
    <?php } ?>
<?php } ?>
 
//2. Add this tracking code on the cart page
_veroq.push(['track', 'views cart']);
 
//3. Add this code on every step of the checkout, particularly the first step after you get the customer's email.
// Note that you need to cycle through each product in the cart. I have used 'product_array' as a placeholder as
// I don't know how to retrive the list from Magento (it's been a while!)
var products = [];
for(var i=0;i<product_array.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);
}
_veroq.push(['track', 'reaches checkout step X', {products: products}]);