Google Analytics

Google Analytics enables you to track the visitors to your store, and generates reports that will help you with your marketing.

Follow these instructions to enable Google Analytics through your general settings. We strongly recommend that you use only this method to enable Google Analytics on your website.

Before you begin

Before you begin, you'll need to:

Making sure Google Analytics isn't already enabled

In general, Google Analytics should only be enabled once, otherwise tracking will be inaccurate. Before you begin, make sure that none of the following tracking scripts are present in your theme.liquid file:

  • ga.js
  • dc.js
  • analytics.js.

The presence of any of these scripts indicates that Google Analytics is already enabled on your site. Unless you have a specific reason, we recommend removing any existing tracking script from your theme before you continue with these instructions.

To inspect your site and check for any potential problems, install Google's Tag Assistant. If there is an issue such as multiple tracking scripts, you'll see an error message when you visit your site, for example:

  • Error: Detected both ga.js and dc.js scripts which will make tracking ambiguous.
  • Multiple Google Analytics tags detected.

Getting a Google account

Before you can enable Google Analytics, you’ll need a Google account. If you already have a Gmail account, you'll be able to use that. If not, create your Google account here.

Enabling Analytics

Shopify officially supports and recommends using Universal Analytics, which is the latest version of Google Analytics.

Although Shopify also supports the usage of Classic (Asynchronous) Analytics, you should use Universal Analytics unless you have specific implementation requirements. Universal Analytics has all the functionality of Asynchronous Analytics in addition to new features.

1. Begin by going to the Google Analytics homepage and click the create an account link in the top right corner.

#

2. On the next page, click Sign in or create new account.

3. Click Website, not Mobile app, and fill in the form. Enter your primary domain for the Web Site URL. The checkboxes at the bottom are not relevant.

Click Get Tracking ID at the bottom of the page to complete signup.

#

4. On the next page, you'll see a lot of information and options. The only thing you need is the code snippet that Google provides. It looks similar to this:

<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-########-#', 'yourwebsite.com');
  ga('send', 'pageview');

</script>

(You can find the code snippet at any time from your Google Analytics Admin. Choose Settings, then Tracking Info, and scroll down to find the tracking code.)

5. Copy the code snippet to your clipboard by highlighting it and pressing Cmd-C (Ctrl-C on PC).

6. Open your Shopify store Admin in a new browser window.

7. In your Shopify Admin, go to the Settings > General page.

#

8. Paste your Tracking code into the Google Analytics code field. If you're upgrading from Classic Analytics to Universal Analytics, you would first need to click the (change?) button next to your current account number, UA-XXXXXXX-X.

#

Reminder

Don't put any code in the add additional Javascript field unless you want to support Display Advertising.

9. Make sure you've removed password protection from your storefront, otherwise Google Analytics won't be able to track visitors.

Turning on Ecommerce tracking

Shopify also supports Google's Ecommerce tracking. The code is added automatically, but you must enable Ecommerce tracking in Google Analytics if you want Ecommerce data to be included in your reports:

  1. Click Admin from the menu bar at the top of any screen in Google Analytics.
  2. Use the drop-down menus to select the Account, Property, and View.
  3. Click View Settings.
  4. Scroll down to the Ecommerce Settings section, and click the toggle so it says ON.
  5. Click Save at the bottom of the page.

Excluding referrer domains

Reminder

This feature is only available if you're using Universal Analytics.

To ensure that domains you don’t want attributed as referrals are excluded:

1. In your Google Analytics Admin, click on your Tracking Info.

#

2. Make sure you have the following domains in your Referral Exclusion List:

  • yourwebsite.com (the primary domain of your site, you may have more than one)
  • checkout.shopify.com
  • paypal.com (if you’re using PayPal)
  • any other external payment gateways you are using.

You can read more about referral exclusions here.

Supporting Display Advertising

After you've enabled Google Analytics in your store, you might also want to support Display Advertising:

1. Go to the Settings > General page in your Shopify Admin, and find the Google Analytics section.

2 Copy+paste the following code in the Additional Google Analytics Javascript field:

ga('require', 'displayfeatures');
#

3. Be sure to update your store’s privacy policy if necessary.

Information

Read more from Google about Display Advertising here.

Goals and Funnels

Check out this article about Goals and Funnels in Google Analytics.

Discrepancies in reporting

It’s not unusual to notice discrepancies between the traffic reported on your Shopify Dashboard and the data provided by Google Analytics. Unfortunately, it’s impossible to know exactly how to account for these differences and resolve the discrepancy.

There are many possible reasons for differences in tracking results, including:

  • Differences in how page reloads and unique visitors are counted. Google counts every page reload, but a browser won’t count reloads of cached pages.
  • Differences in how page visits are defined. For example, some analytics software counts search bots as visitors, while other software doesn’t.
  • Google can only count visitors with javascript and cookies enabled. Some visitors might not allow cookies or javascript.
  • Discrepancies might be introduced because of different reporting timezones. Read about changing your Google time zone here.
  • It’s unlikely that identical tracking mechanisms are being used, so your visitors will not be recorded equally. Details of recording mechanisms are proprietary information and are never shared.

You can read more about discrepancies in analytics data here.

Ready to put what you've learned into action?

Build an online store with Shopify. Try it free.

Experience the future of retail now.

Shopify Point of Sale. Try it free.