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:
- Using the built-in tracking in Shopify’s store preferences
- Using Littledata’s advanced Shopify to Google Analytics app (which we’ll explain more later)
- Adding GA tags within Google Tag Manager (via GTM)—which is possible in combination with option 1
- 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 up||Completeness of data||Who maintains it|
|Shopify in-built tracking||MINUTES||LOW||– *|
* 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:
- 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
- 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’s
- Click on the Show advanced options link and then toggle the switch on the right to Create a Universal Analytics property
- Then enter a website URL and opt to create a GA4 property as well if you need it
- Next, complete GA’s simple survey
- 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
- Now you can copy the tracking ID starting with “UA-”
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:
- From Admin, go to Sales Channels .. Online Store … Preferences
- 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.
- Set up a new web container in GTM
- Copy the GTM container code to use in your store
- 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)
- Create a new Google Analytics settings variable and paste in your Google Analytics tracking ID from above
- Enable Enhanced Ecommerce tracking for that variable
- 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
- Create a pageview tag using those settings and a trigger
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.
- From your Shopify admin, go to Settings > Checkout
- Under Order processing, go to the Additional scripts text box
- 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)
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.