Google Analytics

AdminSettingsGeneral

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.

Unless you're just planning to upgrade a working installation to Universal Analytics, you must 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're upgrading or have another specific reason to keep these scripts, we recommend removing them 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.

Upgrade to Universal Analytics from Classic

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.

If you're already running Classic Analytics, you can upgrade from your General Settings in the Admin:

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

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

3. Scroll down to the Google Analytics section, then click Upgrade to the latest version.

#

Enable Universal Analytics

To enable Universal Google Analytics:

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 account field.

#

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

You can implement Google's Ecommerce tracking at two different degrees of detail:

The code is added automatically, but you must enable Ecommerce tracking at the view level in Google Analytics, to ensure that Ecommerce data is included in your reports.

Enable basic ecommerce tracking

  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 that you want to track.

    #

  3. Click Ecommerce Settings.

  4. At Step 1 of the Ecommerce setup, click the Enable Ecommerce Status toggle to ON.

    #

Your basic setup is complete. If you need more detailed tracking information, you can enable Enhanced Ecommerce tracking.

Enable Enhanced Ecommerce tracking

Reminder

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

To enable Google's Enhanced Ecommerce tracking:

  1. From your store Admin, click Settings to go to your General Settings.

  2. Scroll down to the Google Analytics section and click the Use Enhanced Ecommerce checkbox.

    #

    Unless you're running the latest version of Google Analytics, you'll have to click Upgrade to the latest version:

    #

    If you're not using a responsive checkout, you'll also need to click upgrade to Responsive Checkout:

    #

  3. Click Save.

  4. In Google Analytics, click Admin from the menu bar at the top of any screen.

  5. Use the drop-down menus to select the Account, Property, and View that you want to track.

    #

  6. Click Ecommerce Settings.

  7. At Step 1 of the Ecommerce setup, click the Enable Ecommerce Status toggle to ON.

    #

  8. Click Next step.

  9. Click the Enable Enhanced Ecommerce Reporting toggle to ON.

    #

  10. Click Submit to complete the setup.

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.