Manually Adding Google Universal Analytics To Your Site

Forum Forums Tutorials Manually Adding Google Universal Analytics To Your Site

This topic contains 0 replies, has 1 voice, and was last updated by  lexiconn 9 years, 12 months ago.

Viewing 1 post (of 1 total)
  • Author
  • #49006


    If you are looking to use Google Universal Analytics to track your ShopSite store and you’re using ShopSite to generate all your pages you can configure ShopSite to add the tracking code for you automatically (requires version 12.0.2). This can be done in the ShopSite back office under Merchandising > Google Services > Analytics.

    The feature has a wizard which will step you through the process of configuring the settings and when you publish your store ShopSite will automatically add (or update existing) tracking code to the store and shopping cart pages.

    If you have pages generated outside of ShopSite or you have a need for customized Universal Analytics tracking code you will need to add the code manually to your site. In this tutorial we’ll step through the details on how to do that and will provide sample tracking code as well.

    For an in-depth look at the features included with Universal Anaytics you can visit:

    To upgrade your Google account to Universal Analytics, follow the instructions at:

    Page View Tracking

    If you have your own SSL certificate for your domain name, then you will use the following code:

    Universal Analytics Code

    <!-- BEGIN: Google Universal Analytics -->
    <script type="text/javascript">
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      ga('create', 'UA-XXXXXX-Y', 'auto');
      ga('send', 'pageview');
    <!-- END: Google Analytics -->

    If your store is hosted with us and uses our shared SSL to secure pages, then you will need to use the following code:

    Universal Analytics Code (Cross-Domain Tracking)

    <!-- Google Analytics -->
    <script type="text/javascript">
    (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','//','ga'); function __utmLinkPost(a){return true;}function __utmLinker(a){window.location=a;}
    ga('create', 'UA-XXXXXX-Y', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', ['', '']);
    ga('send', 'pageview');
    <!-- END: Google Analytics --> 

    NOTE: Be sure to change the “UA-XXXXXX-Y” text to your “UA” tracking code provided by Google. Also, “” should be replaced with your domain name.

    For further reading about cross-domain tracking, Google has details here:

    The tracking code selected above goes on every page of your site, including cart pages.  For the tracking code to work, it must be placed before the closing “</head>” tag.  For the shopping cart, the tracking code should be added to the following sections only:

    [-- DEFINE ShoppingCart --]
    [-- DEFINE Shipping --]
    [-- DEFINE Confirmation --]
    [-- DEFINE ThankYou --]

    Ecommerce Tracking (optional)

    In order to track conversion details using Universal Analytics, the following code will need to be added to the [-- DEFINE ThankYou --]  section of your shopping cart template.  The  ecommerce code must be added after the page view tracking code and should be located between the opening “<body>” and closing “</body>” tags.

    <!-- BEGIN: Google Universal Analytics Ecommerce Tracking Code -->
    <script type="text/javascript">
    document.write('<script type=\"text/javascript\">');
    document.write("ga('require', 'ecommerce', 'ecommerce.js');");
    document.write("ga('ecommerce:addTransaction', {" + "'id':'" + ss_ordernum +"', 'affiliation':'" + ss_associate + "','revenue':'" + ss_ordertotal + "','shipping':'" + ss_shiptotal + "','tax':'" + ss_taxtotal + "'});");
         for (var p = 0 ; p < number_products ; p++) { 
         document.write("ga('ecommerce:addItem', {" + "'id':'" + ss_ordernum +"', 'name':'" + ss_name[p] + "','sku':'" + ss_sku[p] + "', 'category': 'product', 'price':'" + ss_price[p] + "','quantity':'" + ss_quantity[p] + "'});");      } document.write("ga('ecommerce:send');"); document.write('<\/scr'+'ipt>'); </script> <!-- END: Google Analytics Ecommerce Tracking Code -->

    Tip:  For conversions to be reported, your Google Analytics account must be upgraded to Universal Analytics and Ecommerce Tracking enabled.

    Instructions for enabling Ecommerce Tracking in your Google Analytics account can be found at:

    Google has additional details on the eCommerce tracking features of Universal Analytics here:

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.