Browse by Topic

Setting Up Google Analytics

Google Analytics is a free analytics tool that helps you track visitors and conversions on your store. To set up Google Analytics, you will need to create a free Google account.

 

Note: Google recently introduced a new web tagging library called Global Site Tag (gtag.js). Global Site Tag is still in beta. The Global Site Tag (gtag.js) is not supported at this time. You can continue to use your existing tracking setup and Google's Universal Analytics library (analytics.js) which this article is referencing.

 
 

Basic Tracking Code

These steps will show you how to set up basic tracking for a website and generate its tracking code in Google Analytics. If you wish to track additional metrics (e.g. conversion rate), skip ahead to E-commerce Tracking. Ecommerce tracking provides analytical data such as total revenue, the rate of conversions, and the number of unique purchases made.

1. Sign into or create your Google Analytics account.

2. Click Admin.

Admin button

3. Under Account, select Create a new account.

Create New Account

4. Complete the form, then click Get Tracking ID.

Get Tracking ID

5. Copy the following tracking code, beginning with <script> and ending with </script>.

<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','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-XXXXX-Y', 'auto');
    ga('send', 'pageview');
</script>

6. Proceed to Installing the Tracking Code.

 
 

E-commerce Tracking

If you wish to see E-commerce tracking in your Google Analytics reports, the code below should be entered instead of the basic tracking code.

 

E-commerce tracking: You must have a dedicated SSL as this feature does not work with the shared .mybigcommerce.com SSL certificate.

1. In your Google Analytics account, go to AdminViewEcommerce Settings.

Ecommerce Settings

2. Under Enable Ecommerce, toggle the status to ON. Click Next Step.

Enable Ecommerce switch and Next step button

3. Leave Enhanced Ecommerce Settings set to OFF. Click Submit.

Enhanced Ecommerce Settings swtich and Submit button

4. Copy the following tracking code. Be sure to copy the entire code, beginning with <script> and ending with </script>.

<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', 'UA-xxxxxxxx-x', 'yourdomain.com');
    ga('send', 'pageview');
    ga('require', 'ecommerce', 'ecommerce.js');

    function trackEcommerce() {
    this._addTrans = addTrans;
    this._addItem = addItems;
    this._trackTrans = trackTrans;
    }
    function addTrans(orderID,store,total,tax,shipping,city,state,country) {
    ga('ecommerce:addTransaction', {
        'id': orderID,
        'affiliation': store,
        'revenue': total,
        'tax': tax,
        'shipping': shipping,
        'city': city,
        'state': state,
        'country': country
    });
    }
    function addItems(orderID,sku,product,variation,price,qty) {
    ga('ecommerce:addItem', {
        'id': orderID,
        'sku': sku,
        'name': product,
        'category': variation,
        'price': price,
        'quantity': qty
    });
    }
    function trackTrans() {
        ga('ecommerce:send');
    }
    var pageTracker = new trackEcommerce();
</script>

5. Continue to Installing the Tracking Code.

 
 

Installing the Tracking Code

Once you have successfully generated the tracking code, it will need to be installed in your BigCommerce store.

1. In the BigCommerce control panel, go to Advanced SettingsWeb Analytics.

2. Check the box next to Google Analytics, then Save.

Google Analytics checkbox

3. Click the Google Analytics tab that appears at the top of the page.

Google Analytics tab

4. Paste the tracking code into the Tracking Code field. Replace UA-xxxxxxxx-x and yourdomain.com with your Google Tracking Number and your store's domain.

Basic Tracking Code

Tracking Code

E-commerce Tracking Code

Google Analytics Ecommerce Tracking code pasted in the Tracking Code field

5. Save your changes.

 
 

Excluding Referrals From Hosted Payment Gateways

To avoid transactions made through a hosted gateway such as PayPal appearing as referrals through Google Analytics, you will need to add the payment gateway to your Referral Exclusion List.

1. In your Google Analytics account, go to AdminPropertyTracking InfoReferral Exclusion List.

Tracking Info and Rferral Exclusion List

2. Click Add Referral Exclusion.

Add Referral Exclusion

3. Enter the domain of your payment gateway (e.g. paypal.com) in the Domain field.

4. Click Create.

Was this article helpful?