Google Universal Analytics - Enhanced Ecommerce for Magento

Note that these modifications are optional! Without it, you will just not have impressions & clicks informations.

You will need to add some modification to your theme if you want to benefit fully the Enhanced Ecommerce plugin. You will find on this page the documentation to manage Product Impressions, Product clicks, Promotion Impressions and Promotions clicks

Product impression tracking

You'll have to add a PHP code whenever a product is displayed on list. For example, you'll want to start with catalog/product/list.phtml template.

To track a product Impression, you'll have to add this code :

    
        <?php echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getAddProductImpressionTag($_product, false, $i) ?>
    

The parameters of getAddProductImpressionTag method are :

  1. The product. Required. This must be a 'catalog/product' model.
  2. The list name. Optional. If you leave it to false, our extension will try to guess a list name. For example : "Category Electronics Product List".
  3. The position of the product on the list. Optional. On list.phtml template, you will want to use $_iterator variable for list mode, and $i for grid mode.

You have to place this code whenever a product is displayed in a list, inside a <li> for exemple.



Product click tracking

You'll have to add a PHP code whenever a link to a product view is displayed. For example, you'll want to start with catalog/product/list.phtml template.

To track a product clicks, you'll have to add this code :

    
        <?php  echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getProductLinkData($_product, false, $_iterator) ?>
    

The parameters of getProductLinkData method are :

  1. The product. Required. This must be a 'catalog/product' model.
  2. The list name. Optional. If you leave it to false, our extension will try to guess a list name. For example : "Category Electronics Product List".
  3. The position of the product on the list. Optional. On list.phtml template, you will want to use $_iterator variable for list mode, and $i for grid mode.

You have to place this code whenever a link product is displayed in a list, inside the <a> tag, for example :

    
        <a <?php echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getProductLinkData($_product, false, $_iterator) ?> 
        href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>">
    


Promo impression tracking

You'll have to add a PHP code whenever a promo is displayed. For example, you'll want to start with callouts/*.phtml templates, or your homepage banners.

To track a promo Impression, you'll have to add this code :

    
        <?php echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getAddPromoImpressionTag('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?>
    

The parameters of getAddPromoImpressionTag method are :

  1. The promotion ID. Required.
  2. The promotion name. Optionnal.
  3. The creative associated with the promotion. Optionnal.
  4. The position of the promotion. Optionnal.

You have to place this code whenever a promo (that you want to track) is displayed, just after the banner <img> tag for exemple.



Promo click tracking

You'll have to add a PHP code whenever a link to a promo is displayed.

To track a promo clicks, you'll have to add this code :

    
        <?php  echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getPromoLinkData('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?>
    

The parameters of getPromoLinkData method are :

  1. The promotion ID. Required.
  2. The promotion name. Optionnal.
  3. The position of the promotion. Optionnal.

You have to place this code whenever a link to promo is displayed, inside the <a> tag, for example :

    
        <a <?php echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getPromoLinkData('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?> 
        href="<?php echo $this->getUrl('promotions') ?>" title="<?php echo $this->__('Summer Sales !'); ?>">
    


Notes

You may want to factorize this code to get it more clean, and shorter. For example, you can add this code oo the top of your template :

    
        $_guaEc = $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data');
    

So you can replace $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data') with $_guaEc in the codes above, for example :

    
        <?php  echo $this->helper('\Webcooking\GoogleUniversalAnalytics\Helper\Data')->getPromoLinkData('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?>
    

will become :

    
        <?php  echo $_guaEc->getPromoLinkData('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?>
    

Better, isn't it ?



Finally, we are sorry to put your hands into the code, it should be our job! However, we cannot detect all your promotions, and product's impressions/links :) Especially since you have a very customized (and so beautiful) theme, right ?

We hope our extension will help you in your business! Cheers!