Jump to content

Photo

Universal Analytics Web Tracking

Google Analytics

  • Please log in to reply
No replies to this topic

#1 Michael Herzog

Michael Herzog

    SmartStore AG

  • Administrators
  • 3498 posts

Posted 01 October 2015 - 15:09

To use the new tracking script for Google Universal Analytics Web Tracking the following script should be entered in the widget configuration Admin > CMS > Widgets > Google Analytics > Configure.

 

Tracking code with {ECOMMERCE} line

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', '{GOOGLEID}', 'auto');
  ga('send', 'pageview');

  {ECOMMERCE}
</script>

Tracking code for {ECOMMERCE} part, with {DETAILS} line

ga('require', 'ecommerce');

ga('ecommerce:addTransaction', {
  'id': '{ORDERID}',         
  'affiliation': '{SITE}',   
  'revenue': '{TOTAL}',      
  'shipping': '{SHIP}',      
  'tax': '{TAX}',
  'currency': 'EUR'             //'currency': '{CURRENCY}'
});

{DETAILS}

ga('ecommerce:send');

Tracking code for {DETAILS} part

ga('ecommerce:addItem', {
  'id': '{ORDERID}',
  'name': '{PRODUCTNAME}',
  'sku': '{PRODUCTSKU}',  
  'category': '{CATEGORYNAME}',
  'price': '{UNITPRICE}', 
  'quantity': '{QUANTITY}' 
});

The currency parameter cannot be replaced with the current version of the plugin. You can configure it global for all ecommerce transactions within google analytics by going to Manage > Data Settings > Currency will be displayed as or define it within the script as it is done in code block two of this post. With the current version of the plugin, which is available for download in the marketplace, the line can be written with a replacement parameter 'currency': '{CURRENCY}'.


  • Stephennuh, GalenKa, RidgeOi and 1 other like this

Michael Herzog
Smartstore AG



Also tagged with one or more of these keywords: Google Analytics