How to add Google Analytics to Shopify

shopify and google analytics data mismatch
create a universal analytics property

Google Analytics is the world’s most popular marketing analytics platform, used by 98% of online stores. Shopify is the world’s most popular ecommerce platform, used by over two million active merchants.

But these two popular platforms don’t work together automatically. We’ll show you how to get Shopify to work with Google Analytics, and some of the common problems and solutions when adding Google Analytics to Shopify.

Read on to learn step by step how you can add Google Analytics to Shopify, or jump to the section that answers your question in the guide below.

1. What are the options for adding Google Analytics to Shopify?
2. The First Step: Creating a Google Analytics property for Shopify
3. Option 1: Shopify’s in-built tracker
4. Option 2: Using Littledata
5. Option 3: Adding GA tags within Google Tag Manager (via GTM)
6. Handling refunds and recurring orders
7. Top seven things to check after adding Google Analytics

Why add Google Analytics to Shopify?

With the advent of Shopify Analytics, some of our customers ask why they need Google Analytics (GA) at all. Yet, GA has continued to be the most popular choice for web analytics since launching in 2007.

Tip: Download our free ebook to learn why Shopify Analytics data doesn’t match Google Analytics

Shopify Analytics can answer some questions about products and revenue on your store. But, there are many important questions Google Analytics is better at answering. Things like:

  • How your orders correspond to multiple marketing touchpoints
  • Who your web visitors are, segmented by location, demographics, and page interactions
  • Which shopping behaviors and ecommerce funnels drive revenue (with more detail than Shopify Analytics)
  • How to sync audiences or conversion data with Google Ads to improve ad targeting
  • How your Shopify store’s performance compares with previous years on another ecommerce platform

To get all that juicy extra reporting, you will need to first add Google Analytics Enhanced Ecommerce tracking to your store.

What is Enhanced Ecommerce tracking?

If you want to track your customers in Google Analytics, you don’t just need to track the page views—which is easy. You also need to see key parts of the buyer’s journey, especially the purchase itself (with the order value).

Google calls this Enhanced Ecommerce tracking: measuring the full customer journey—and what products got to which stage of the journey—from the product listing page, through adding to cart, all the way to checkout and purchase.

This type of ecommerce tracking is a bit harder to set up. You need data about your product variants, SKUs, prices, and quantities available to send to Google.

Enhanced Ecommerce is Google’s best solution for ecommerce analytics. It gives you a way to analyze not just the campaigns that led to pageviews, but how users interacted with products and payments.

What are the options for adding Google Analytics to Shopify?

For Universal Analytics

Universal Analytics (UA) was the default for GA prior to 2020. You can tell if your store has Universal Analytics already because your web property ID will start `UA-` and then a string of numbers. To connect Shopify to Universal Analytics, your options are:

  1. Using the built-in tracking in Shopify’s store preferences
  2. Using Littledata’s advanced Shopify to Google Analytics app (which we’ll explain more later)
  3. Adding GA tags within Google Tag Manager (via GTM)—which is possible in combination with option 1
  4. Pasting the gtag snippet directly into your store layout (not our recommended option as it makes maintenance of the tracking hard)

Adding Google Analytics 4

Since October 2020, GA4 has been the default when setting up any new Google Analytics properties. GA4 brings a number of advantages, including faster, smarter reports, but unfortunately GA4 is not yet supported by Shopify—so using their built-in tracking is not possible.

Note: There is still a way to create a new Universal Analytics property (see below) so you can choose any option above.

What is the best way to add Google Analytics to Shopify?

The method you choose for adding Google analytics to Shopify depends on your need for data completeness and accuracy as well as how much time you have to configure the setup. Achieving a good GTM implementation can take many days of experimentation. Even then, it can be liable to break when making edits to your theme.

 Time to set upCompleteness of dataWho maintains it
Shopify in-built trackingMINUTESLOW– *

* We haven’t seen any updates to Shopify’s GA tracking since they launched enhanced ecommerce reports back in 2016

The First Step: Creating a Google Analytics property for Shopify

Whichever route you take, you’ll need to set up the web property in Google Analytics to receive the data.

To do this, follow each step listed below:

  1. Under the admin settings (cog in the bottom left), click on the blue +CREATE PROPERTY button. If you don’t see the button, you need someone with edit permissions on the account to set this up for you
  2. Add a name for the property, and set the currency and timezone to match the currency and timezone in your Shopify store. This will ensure daily revenue and metrics closely match Shopify’screate GA property
  3. Click on the Show advanced options link and then toggle the switch on the right to Create a Universal Analytics property
  4. Then enter a website URL and opt to create a GA4 property as well if you need it
  5. Next, complete GA’s simple survey
    Google analytics survey
  6. Once complete, Google will take you to the GA4 property first. So navigate back to the admin page, and find Property … Tracking Info … Tracking code
    GA tracking code
  7. Now you can copy the tracking ID starting with “UA-”
    Google Analytics tracking ID

Now that you have your GA property set up to receive data, it’s time to add Google Analytics to your Shopify store.

Option 1: Shopify’s in-built tracker

If you want to use Shopify admin to set up the tracking, you can paste that tracking ID straight in by following these steps:

  1. From Admin, go to Sales Channels .. Online Store … Preferences
  2. Paste in the tracking ID to Google Analytics account section and SAVE

Note: You can ignore the “latest version” of Google Analytics. They mean Universal Analytics… see what I mean about it not being maintained?

Option 2: Using Littledata

You can follow Littledata’s Getting Started guide to add Google Analytics to your Shopify store in a few minutes. 

Without any extra effort on your part, Littledata gives you much more complete data in GA and weekly updates to your tracking as Google and Shopify launch new features.

Littledata also supports GA4 setups, and we encourage GA users to start a property and track there ASAP.

Tip: Get our GA4 migration checklist to start using the newest version of analytics with ease.

Option 3: Adding GA tags within Google Tag Manager (via GTM)

If you prefer total control of how you add Google Analytics to Shopify, then using GTM could be the best option.

  1. Set up a new web container in GTMcreate container GA
  2. Copy the GTM container code to use in your store
  3. EITHER… Add the GTM container snippet to the theme.liquid file, just before the closing </head> tag. This will include the container in all pages except for the checkout and order confirmation page. (Note: Shopify Plus stores can also add the snippet to the checkout.liquid file to add to the checkout page)GTM snippet checkout.liquid
  4. OR… use the box for ‘Additional Javascript’ to add it to all pages, including the order confirmation page (though this is being phased out for new stores). You need to leave out the starting <script> and ending </script> tags as this box is for Javascript, not HTML
  5. Create a new Google Analytics settings variable and paste in your Google Analytics tracking ID from above
  6. Enable Enhanced Ecommerce tracking for that variable
  7. Create a trigger for when the page DOM loads. This is considered a more reliable measure of the user ‘viewing’ a page than just firing it when GTM first loads
  8. Create a pageview tag using those settings and a triggerGA preview tag

Tracking the “thank you page” with GTM

The “thank you page” (or order completed page) is most critical to track; not just the pageview but the purchase value itself.

First, you have to add the GTM container. In Shopify store preferences, if you still see the Additional Javascript box you can add the container code there. If not, you can also add the container in the Additional Scripts section of the checkout page.

  1. From your Shopify admin, go to Settings > Checkout
  2. Under Order processing, go to the Additional scripts text boxtrack thank you page GA
  3. Paste in the GTM container

To send ecommerce data such as the order value and product SKUs to Google Analytics as well, you need to build a data layer based on the Shopify Order object. That is out of scope for what this guide covers.

For a valid enhanced ecommerce transaction event, you’ll need at least the following fields:

  • Order ID
  • Order value
  • Product IDs (or SKUs)

Tip: Did you know? Littledata’s app provides a GTM data layer for the order object, and a ready-made variable template to use that data in GTM.

Handling refunds and recurring orders

Some customer events (like refunds) happen without an accompanying page view and are impossible to track with GTM, as there is no browser trigger to hook into. The only way to send them to Google Analytics is with a server-side Google Analytics integration—which is how Littledata works.

This is also true for subscriptions, where recurring orders are sent directly to Shopify’s servers and are not part of a web session. If you want to track the Customer Lifetime Value from a subscription, not just the first subscription order, then Littledata handles recurring orders too.

Handling GDPR consent management

One more topic to consider if you want to add Google Analytics to Shopify using GTM is how to respect customers opting out of tracking, as is their right under European GDPR legislation (Shopify and Littledata’s tracking handle GDPR cookie consent already).

Google released some support for Consent Management this year, but there is no standard integration with Shopify’s customer privacy API. So, you would need to set up triggers for when customers have opted into cookies manually. Again, this is out of scope for this guide.

Top seven things to check after adding Google Analytics to Shopify

Whichever method you choose, here are my tips to make sure you get the most accurate tracking. 

  1. Do you have duplicate tracking? If you add more than one Google Analytics tracker (maybe one via Shopify admin and one via GTM), then you’ll see an artificially low bounce rate (usually below 5%), since every page view is sent twice to Google Analytics.
  2. Is Google Analytics added to every page? This can be hard to check, but you can run through a typical shopping journey and view the real-time pageviews in Google Analytics. The most common issue is with landing page builders (e.g. Gem Pages and Zipify) which don’t use the same Shopify layout.
  3. Are you using the same Currency and Timezone as Shopify? Check your currency and timezone settings in Shopify by going to “Settings” > “General”. For any view in Google Analytics, use these currency and timezone settings. We have seen several store owners worry their sales were inaccurate in Google Analytics compared to Shopify, when the problem was actually that sales were pushed differently between days due to the disparity in these settings.
  4. Are all your country stores tracked? If you have multiple country stores for your brand, then we recommend adding the same Google Analytics property ID to all your stores. You can then create segments in Google Analytics to look at customers in just one country/domain.
  5. Do you see revenue attributed to your top marketing campaigns? Accurate marketing attribution could be blocked by certain third-party checkouts or payment gateways. Go to Acquisition … All Traffic … Channels report in GA and check that all the top campaigns you would expect to be generating sales have sales recorded against them.
  6. Is your internal traffic skewing the reports in GA? Your web developers, content writers and marketers will be heavy users of your own site. You need to filter this traffic out from your Google Analytics data to get a view of genuine customers or prospects.
  7. Have you set up filtered views for reporting? So you can still test the data capture, we recommend you set up a “Raw data” view in GA without filters, then add filters (for spam, internal traffic, etc.) in a reporting view.

How to get the most from connecting Google Analytics to Shopify

Whichever method you choose to get the reporting in Google Analytics, remember that good analytics is not a one-time activity. Every time you make a change to your store layout, traffic acquisition, or checkout options, you need to think about how this will impact your data collection—and the ability to report on your website performance.

For a maintained, robust tracking solution you can try out free trial of Littledata’s Google Analytics app. For even greater setup support, talk to us about account management on a Plus Plan.

Lunch with Littledata: How Wild built an industry-leading brand in 2 years

Lunch with Littledata: How Wild built an industry-leading brand in 2 years

Want to learn from DTC founders and entrepreneurs shaking up their industries?

Littledata announces Google Analytics integration for BigCommerce
faster page load speed ecommerce

Littledata announces Google Analytics integration for BigCommerce

We are excited to announce that Littledata is available to BigCommerce

You May Also Like