How do I migrate from classic to universal Google Analytics?



Follow the below instructions to migrate from classic to Universal Google Analytics.

Go to: 
Admin > 3rd Pary Scripts > Google Analytics

1. Install the following code in header (declaration) section:

<!-- Google Analytics -->
<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', '[@REFERRAL_KEY1@]', 'auto');
[%IF [@CONFIG:CHECKOUT_COMPLETED@] %]
ga('send', 'pageview', {
  'page': '/purchase/invoice.html'
});
[%/IF%]
</script>
<!-- End Google Analytics -->

2. Install the following in the purchase confirmation section:

<!-- Start Google E-commerce Tracking -->
[%SHOW_ORDER id:'[@ORDER_ID@]'%]
[%PARAM *header%]
<script type="text/javascript">
ga('require', 'ecommerce');

ga('ecommerce:addTransaction', {
  'id': '[%URL_ENCODE%][@ORDER_ID@][%END URL_ENCODE%]',                     // Transaction ID. Required.
  'affiliation': '[%URL_ENCODE%][@CONFIG:WEBSITE_NAME@][%END URL_ENCODE%]',   // Affiliation or store name.
  'revenue': '[@GRAND_TOTAL@]',               // Grand Total.
  'shipping': '[@shipping_price@]',                  // Shipping.
  'tax': '[@tax_total@]'                     // Tax.
});

[%END PARAM%]
[%PARAM *body%]

ga('ecommerce:addItem', {
  'id': '[%URL_ENCODE%][@ORDER_ID@][%END URL_ENCODE%]',                     // Transaction ID. Required.
  'name': '[%URL_ENCODE%][@MODEL@][%END URL_ENCODE%]',    // Product name. Required.
  'sku': '[%URL_ENCODE%][@SKU@][%END URL_ENCODE%]',                 // SKU/code.
  'category': '[%URL_ENCODE%][@CATEGORY_NAME@][%END URL_ENCODE%]',         // Category or variation.
  'price': '[@PRICE@]',                 // Unit price.
  'quantity': '[@QTY@]'                   // Quantity.
});

[%END PARAM%]
[%PARAM *footer%]
ga('ecommerce:send');
</script>
[%END PARAM%]
[%END SHOW_ORDER%]
<!-- End Google E-commerce Tracking -->

3. Replace any code in the footer section with the below code:
<!-- Start Google E-commerce Tracking -->
[%IF [@CONFIG:CHECKOUT_COMPLETED@]  eq ''%]
<script>
[%IF [@CONFIG:GA_FUNNEL_VALUE@]%] ga('send', 'pageview', '[@CONFIG:GA_FUNNEL_VALUE@]'); [%ELSE%] ga('send', 'pageview');[%/IF%]
</script>
[%/IF%]
<!-- End Google E-commerce Tracking -->
After making the above changes login to your Google Analytics account, go to the "real time" tracking section and check to see that visitors are being tracked.

  • Last Modified: 19/08/2016