The Finest Google Analytics Setup in Shopify for Splendid Data

Get everything to configure the ultimate Google Analytics for Shopify in this splendid tutorial. Digital Marketing Evangelist for Google and author of Web Analytics 2.0 Avinash Kaushik has called this the “great, detailed, guide on how to set up and get value [in Shopify]”.

A lot of Shopify stores have bad data and no idea how to use their analytics program. Once you complete the guide, you will change how you market your store as you finally make intelligent use of analytics to grow your store.

Reports and analysis are difficult or inaccurate without clean data. A worker in an offline store has the benefit of talking with customers whereas you may never talk with someone who purchased from your Shopify store. The right Google Analytics setup tells you more about your customers than you could otherwise know.

Bake a scone, make a fine cup of English tea, find your monocle, and we shall explore the wonders together. If it is too much for you to handle, see the last section and I can do it. It’s worth the investment. Founder of market research giant ACNielsen, Arthur Nielsen, said, “The price of light is less than the cost of darkness.”

Here is our client checklist for the perfect Google Analytics setup with Shopify:

While Universal Analytics is phasing out in July 1, 2023, it is still the primary way to track Shopify sales. Shopify have not announceed plans to update to GA4. I will update this guide in July to help you migrate over to GA4 in the fullest way possible without third-party solutions.

Google Analytics in Shopify

The Google Analytics for Shopify Checklist by Digital Darts

1. Google Analytics Setup Best Practices:

Get these wrong and all work in Google Analytics becomes hard.

2. Setup Standard Google Analytics:

Collect all the standard Analytics information correctly from your Shopify like where your users visit the store, what pages are most viewed, and what are your slow pages.

3. Setup Enhanced Ecommerce:

Understand visitor interaction with products over the visitor's whole shopping experience.

4. Create Content Groups:

Setup groups of content to understand the purpose and performance of the various types of content on your store. Stop clustering the data of your whole store into one analysis.

5. Setup Cross-Domain Tracking:

Gather accurate data from other domains or sub-domains like a WordPress blog without messing data.

6. Track Internal Search:

Learn what people want from your store. Searchers are buyers.

7. Strip Unwanted Query Parameters:

Consolidate reports about pages that are the same.

8. Enable Google Signals:

Know your most profitable audiences, track users across devices, enable remarketing, and gather additional information for advertising.

9. Setup Funnels and Goals:

See where users drop-off along the checkout process with Goals and the Checkout Behavior report.

10. Use Enhanced Link Attribution:

Better understand user behaviour on pages to help increase conversions.

11. Fix Spam Hits:

Make your analytics more accurate. Protect yourself from bots and competitors.

12. Track Logged-In Users:

See how high-value users logged in to the store interact with it across multiple browsers and devices over the user's lifetime.

13. Identify Organic Search Keywords:

Setup then link Google Search Console to discover organic keyword rankings in Google including clicks, ranking improvements from SEO, and growth opportunities.

14. Configure Third-Party Apps:

Shopify apps that affect the checkout process need to be setup to work with Google Analytics.

15. Get Custom Alerts:

Be notified of any major behavioral changes on your store—from mentions on another website and products that have gone viral on Facebook, to revenue changes or spikes in traffic.

16. Ongoing Best Practices:

How to track marketing campaigns, add annotations for analytics changes or offline campaigns, and keep team member's from messing store data.

17. Report and Analyse:

Don't stop after collection. It's time to report and analyse the splendid data you collected.

18. Review the Results and How to Get Help:

What to look for and how to solve problems. We can do it all for you.

Get The Free Shopify Google Analytics Spreadsheet

Before you begin the tutorial, I created the ultimate 26-point spreadsheet to have by your side that works beautifully with the tutorial. The spreadsheet walks you through the article as you make changes and track edits in one neat page so you get your setup right.

1. Google Analytics Setup Best Practices

Best practices get you rigorous and understandable data. It is a short list of the most important ones you need to be concerned about for your Shopify store to make analytics simple to manage and accurate.

Use Universal Analytics

Classic Analytics is ancient and no longer supported. This guide uses Universal Analytics, which gives you flexibility with custom dimensions to track anything you want. Released at the end of 2017, gtag.js is not native in Shopify’s Google Analytics setup. It doesn’t matter though because you can use gtag.js for dynamic remarketing, Google Ads conversion tracking, and other events outside of this setup.

Use one Google Analytics snippet

Some old Shopify themes are pre-installed with Google Analytics. I haven’t seen this for years though. Check to see if yours does otherwise your data will be wrong. Visit the home page of your site then view the source code to see if any of the scripts gtags.js, ga.js, dc.js, or analytics.js exist. However, trying to spot these four files this way can mean you still overlook Analytics running through Shopify apps or Google Tag Manager.

A more comprehensive method is using the Tag Assistant Chrome extension. If you see duplicate Google Analytics codes in Tag Assistant, that doesn’t mean you have a problem yet. Next, log into Google Analytics. If your bounce rate is less than 10%, you have a problem because multiple codes are sending the same pageview data. Your duplicate analytics code needs be fixed. The method to fix duplicate code varies (likely involving removing the duplicate code or sending a non-interaction event), but using Tag Assistant is a good start.

This tutorial leverages the native Google Analytics setup in Shopify rather than hard-coded in the theme. This way the store is future-proofed with analytics updates done by Shopify and your theme developer.

Use the correct property per domain

If you have two or more websites that do not relate, use separate properties, which means a different analytics ID.

If the websites are similar businesses that serve different regions regardless of their domains, use the same property ID. Setup cross-domain tracking as indicated in the guide to retain the original user information like source and medium. You can use filters to have one view for each store.

Have one raw view

One view should have no filters. It is your benchmark to see what goes on. Name it something like, “Your Store Name – Raw View” or the default “All Web Site Data”. If you already have one view, create a new one then use that as your raw view. (That way the view you work on during this guide, will have your historical data, which is handy for analysis even if it is incomplete or inaccurate.)

The non-raw view(s) will have filters, ecommerce tracking, goals, and all the fancy jazz that changes data you collect. If you setup User ID tracking, you have to configure the view with the steps in this guide to receive clean data.

Track all pages

If you follow this tutorial, you will track all pages in Shopify. Check that Google Analytics is on all web properties related to the business like a support desk or WordPress blog. Any software or app that generates pages through new URLs should be tracked.

Use 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. Several store owners have been worried sales were inaccurate in Google Analytics compared to Shopify, when the problem was sales were pushed differently between days due to the disparity in these settings.

2. How to Setup a Standard Google Analytics in Shopify

1. a) Don’t have a Google Analytics account? Sign-up using your main Google account. Since Shopify’s native setup is incompatible with the Google Analytics 4 tag, when creating a property, show the advanced options to create a Universal Analytics property:

How to create universal analytics property in Shopify instead of GA4

Follow Google’s steps to create an account until you come across your Universal Analytics tracking code to be installed. I recommend you create another property under the same account so the tracking code you use ends in -2 like UA-XXXXXXXX-2. This is a simple way to eliminate a lot of referral spam because most spammers only hit the property UA-XXXXXXXX-1.

Recently I’ve noticed more spammers hitting the -2 property. Conniving idiots! You may even want to use -3.

b) Already have a Google Analytics account? Login then click “Admin” at the top and go to “Tracking Info” > “Tracking Code”:

Google Analytics tracking code section

2. Copy your code that will look something like the below, but with your unique UA ID:

<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-45674565-1');

3. Login to your Shopify store and go to “Online Store” > “Preferences”. You’ll see a Google Analytics section:

Google Analytics in Shopify

4. Paste the Google tracking code you obtained from step 2 of this “Standard Google Analytics Setup” guide, into the “Google Analytics account” field in Shopify. Click “Save”.

You have the basic Google Analytics setup done. Shopify reads the analytics code you pasted to extract the ID and configure your analytics. The code is injected into your theme with the following code then sent to a service called

{{ content_for_header }}

3. How to Setup Google Analytics Enhanced Ecommerce in Shopify

The enhanced ecommerce plug-in for analytics.js enables the measurement of user interactions with products on ecommerce websites across the user’s shopping experience, including: product impressions, product clicks, viewing product details, adding a product to a shopping cart, initiating the checkout process, transactions, and refund.

Shopify is one of the few partners with Google who have made enhanced ecommerce a breeze.

1. In Shopify go to “Online Store” > “Preferences”. Click the checkbox for “Use Enhanced Ecommerce” then click “Save”:

Google Analytics enhanced ecommerce in Shopify

2. Go to your Google Analytics account, click “Admin” then “Ecommerce Settings”:

Google Analytics view section

3. Enable “Ecommerce and “Enhanced Ecommerce Reporting” then save:

Enable enhanced ecommerce

Later in the funnels and goals section of this guide we will cover how to configure other options in Enhanced Ecommerce Reporting to visualise the checkout steps.

4. I recommend you check to confirm your analytics and enhanced ecommerce is setup. Shopify automatically hooks the analytics code in your theme as they have a full pre-built enhanced ecommerce analytics integration. Check the “Ecommerce” report in analytics 24 hours after your first sale following the configurations from this guide. Also do an immediate analysis by viewing the source code of your website. You should see code between the head tags like:

5. This last step ensures one analytics session happens across sub-domains like a blog, your primary domain, and payment gateway. In the “Admin” section of analytics, click “Tracking Info” then “Referral Exclusion List”. Create new referral exclusions for:

  • – The URL of your domain.
  • – The domain of any payment gateways you use. If you use Afterpay, enter If you use Zip Money, enter and If you use Zip Pay, enter If you use Klarna, enter If you use iyzico, enter Go through the checkout process for each gateway then enter the domain of the gateway into the referral exclusion list. If your store accepts Amazon payments, you’ll need to add I’ve also seen that needs to be added to the referral exclusion list. The easiest way to confirm what to add is looking at the referrals report for revenue data from payment gateways.
  • – This use to be in the checkout of stores, but I still notice it in other sources like draft orders.
  • – The domain used by customers during the accelerated checkout process of Shopify Pay.
  • – Shopify’s Shop app and the Shop payment option at checkout. Traffic from this has a utm_source value of No utm_medium is set so it is a referral.
  • – This is the domain of your Shopify admin to exclude referrals from the admin dashboard.

Does the store accept draft orders? You can view the “Sales Performance” report to see that individual transactions for draft orders are excluded. This is because the Shopify.checkout object does not exist for draft orders. A checkout does not exist in the eyes of Shopify even though the payment process looks similar.

4. Create Content Groups

Let’s say you have a blog for your store. You understand the critical part to content marketing: quality and consistency. Your blog does so well that half the people who come to your store read your blog.

The popularity of your blog means most people who visit your website are immediately uninterested in buying your products. Your conversion rate drops. Is this a problem?

Traditional ecommerce analysis and thinking says it is a problem. Ecommerce consultants and store owners would see a drop in conversion rate then panic. You cannot optimise for conversion if you fail to understand the role content-types have on the purchase process.

Content Groups in Google Analytics help you solve this issue. When setup correctly, you can identify the influence your blog, support pages, and other types of content have on purchases.

Given the solution below for content groups is not ideal, my recommendation for most stores is the Digital Darts: Content Drilldown report. The report is built, and works out-of-the-box, for your store because of the reliable URL structure of Shopify. It is a powerful report to frequently analyse:

Content drilldown

To setup content groups:

1. Login to your analytics then go to “Admin”.

2. Select the view who’s data you can edit as per the best practice.

3. Click “Content Grouping” then “+ New Content Grouping”.

4. Cluster all pages on your site into groups. Type your groups into the header row of a spreadsheet with pages you want to cluster in the rows. Record all your pages, but one collection and one product is enough. If you want to be sure you have all pages accounted for, use Screaming Frog’s Spider Tool. Your goal is to cluster the pages into similarities of influencing user behavior:

Content grouping example for a Shopify store

Here are content groups stores could use to better understand user behavior:

  • Blog. Includes blog posts.
  • Collections.
  • Product Pages.
  • Checkout Pages.
  • Marketing Pages. Example pages are ones that talk about your companies values, the manufacturing process, and media mentions.
  • Account Pages.
  • 404 Errors.
  • Support Pages.

5. There are three options to set a content group so you have to pick the ones best for you. Step four makes this step easier. You can use multiple methods in a “and/or logic”:

  • Group by tracking code: the most customised approach that requires you to group pages by a custom JavaScript snippet. Use this as the last resort in Shopify if the other two are insufficient. It requires advanced coding knowledge.
  • Group using extraction: Shopify has a consistent URL structure. Regular expressions for the “Page” option makes this my favorite option. You can use regular expressions based on the URL, page title, or content description value. Extract additional data with parenthesis when possible. What’s inside the parenthesis becomes the group name in reports. All your collections can be broken down into their own group. The rule precedes any rule you may have in “Group using rule definitions”.
  • Group using rule definitions: you won’t use this much but it lets you apply highly customised rules using and/or logic with minimal need for regular expressions.

The trick is to identify commonality of pages you want to group and to ensure no others fall into the group. Here is an example of content grouping for a Shopify blog where all the blog URLs begin like

Content grouping for a Shopify blog

Create up to five content groups now for the columns you created in step four. My standard recommendation uses “Group using extraction” with these regular expression rules suited for Shopify:

  • Collections:
  • Products:
  • Pages:
  • Blogs:

This implementation is imperfect because you would ideally have “Pages” with child elements of “Account”, “Support” and others to separate the diverse user behavior among these category of pages. The best solution likely involves custom tracking code placed throughout the Shopify theme. If you have a solution, please share it in the comments.

Once you are finished with the configuration of your content groups, you can analyse their performance with primary dimensions and segmentation in standard or custom reports.

5. Setup Cross-Domain Tracking

If you have a sub-domain (such as a WordPress blog or Zendesk help center) with the same analytics ID as your Shopify store, all the data in Google Analytics lumps together as if were URLs on your store. It makes reporting inaccurate and analysis difficult.

Let’s say your WordPress blog is hosted on another domain. If someone clicks a Facebook link to a blog post on your WordPress then goes to your store, you won’t know the person came from Facebook. Google Analytics will think the person on your store came from the blog rather than Facebook. The traffic source will be labeled as (direct)/(none).

Use the Shopify Buy Button on another website? Your analytics will have sales attributed to the wrong traffic source. Refer to Malik’s guide on what to do.

Inside Google Analytics, go to your “All Pages” report then from the secondary dimension field, select “Hostname”. You will see websites where your analytics snippet is used:

Sub-domain hostname data in Shopify

If you have a blog on, you will see that hostname. If you have linked YouTube with analytics, you will see the hostname.

It’s time to clean this up so you can view the full domain in your reports and setup cross-domain tracking:

1. Any domain you own or sub-domain that you don’t want to start a new session, add each to the Google Analytics referral exclusion list. That’s all you need to do. Use the same analytics ID on the domains because visitor information cannot be shared across Google Analytics properties.

2. If you own another domain like a WordPress blog at, you need a special tracking code on all pages you want to track otherwise the original traffic source is lost between domains. We are able to use the latest gtag.js for cross-domain tracking recommended by Google because it will be used outside of Shopify. Paste the following after the opening <body> tag on your WordPress blog or non-store domain you want to track. Replace the two instances of XXXXXXXX-X with your analytics ID and with the domain of your store:

<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXXXX-X', {
  'linker': {
    'domains': ['']

The linker parameter appends all links (on pages that have the tracking code installed) that point to with the ?_ga= query string. Google looks at this data to gather hit information then unify the session.

3. If your store links out to, you need to update your Shopify code so it appends the ?_ga= query string to such links. The Shopify analytics code loads the allowLinker plugin along with ga('require', 'linker');. You just need to add the following autoLink code to the “Additional Google Analytics JavaScript” section within Shopify:

ga('linker:autoLink', ['']);

This uses the analytics.js linker plugin here inside Shopify because Shopify does not use gtag.js. The original analytics snippet you pasted into Shopify uses gtag.js, but Shopify only extracts the UA ID from it.

4. Go to “Admin” in your Google Analytics. Under your filtered view, click “Filters”. Create a new filter in the view by going to “Filters” then “+ New Filter”.

5. Name the filter something like “Append blog subdomain”. Select “Custom”, select “Include” then select “Hostname” as the filter field.

6. Replace “” with your full sub-domain. Ensure there is parenthesis around it like the example below. This keeps historical data on the primary domain clean. Save it. Your filter will look like:

Sub-domain tracking Shopify and WordPress

Use (.*) instead of ( in the hostname field to reveal the full URL for all domains.

People who search your store can be 43% more likely to convert than people who don’t.

It’s time to extract value from this data to drive sales. The search tracking configuration in analytics lets you see what people search on your store and their whole visitor journey.

You want a search field on your store if you stock a large number of products. It’s good usability.

You only need to setup search tracking if your store has a search field. Search tracking in Google Analytics lets you know what people search on your store so you discover what they want to find. The information lets you see how people who search arrive on your store, how you can better provide what people want, and opens ideas to product opportunities. Each can boost revenue.

One example I discovered working with a fashion label was people who visited the store from one online forum were trying to find a non-existent accessory. It was no longer created so we wrote a piece of blog content describing the problem the accessory solved, mentioned its name (so it would be discovered in search), and referenced a better solution. Sales from this traffic source increased overnight.

To setup search tracking for your Shopify store:

1. Type any term in the search box on your live store.

2. Look at the URL where your search term appears. You want the query string variable assigned to your search term. This is the bit after the respective ampersand and before the equals sign. In the first example, it is “q”:

It is “b” in the second example:

3. Go to your analytics account go to “Admin” > “View Settings”.

4. Turn on “Site search tracking”.

5. Enter the letter or word you discovered from step two of this search tracking guide in the query parameter box.

6. Click to tick “Strip query parameters out of URL”:

Search tracking in Shopify

7. Sometimes internal searches in Shopify can contain a second parameter that permits the search to apply to specific page types, such as products. If your store has a special category search with a query string that gets included, get the query parameter with the same method from the second step then add that in this field. If the search URL is /search?type=product&q=test, you’d add “type”.

8. Save and you’re setup. Like all non-real-time Google Analytics data, it takes 24 hours for data to appear. You can view the data inside your Shopify Analytics panel or in Google Analytics at “Behavior” > “Site Search”:

Site search reporting

If you’re an advanced analytics user, there’s a “Performed Site Search” segment pre-built that lets you segment data to hopefully extract more value. In my fashion garment example, I used this segment combined with a referral traffic report.

7. Strip Unwanted Query Parameters

In the section on internal search tracking, you excluded a query string of “q” from being included in URLs. This consolidates search pages reported in Google Analytics into /search so that reports on each of the pages look like:

If you do not remove the search query parameter, a page such as /search?q=orange+dress will be reported for every unique search. This doesn’t make sense to have in helping analytical decisions. Similarly, there are many other query parameters a store can use that make sense to exclude especially “variant” for product pages.

1. Inside Google Analytics, go to your “All Pages” report.

2. Add a filter of “?” to identify pages that contain a query parameter. Browse the list of pages to see what parameters are used that make sense to consolidate.

3. Add the list to the “Exclude URL Query Parameters” section in your View Settings. Here’s a template list I’ve developed after doing the analytics for dozens of stores, that you can add:


8. Enable Google Signals

For Google Analytics in 2019, you had access to remarketing and advertising reporting features. By enabling these, you could retarget people who visited the store and you would get access to a demographics report in the “Audience” section. You could then see how each age and gender segment behaves on the store.

Advertising Features have been upgraded to Google signals. When Google signals is enabled, you gather cross-device data, demographic data, and additional information about users for advertising as well as enabling remarketing with Google Ads. All four features are achieved by associating visitor information with users signed into their Google account who have consented to this association for the purpose of ads personalization.

The feature requires no customization of your Shopify store or additional code. There are only two actions required: enabling the feature and adhering to policy.

In Google Analytics, go to Admin > Tracking Info > Data Collection. Follow the prompts to enable the feature. By enabling Google signals, you must adhere to the Google Advertising Features Policy.

As a bonus, take my custom report that uses enhanced ecommerce and demographic data to identify profitable age groups and gender. Sort by average order value and buy-to-detail rate to discover your high-value demographic segments:

Custom enhanced ecommerce demographics report

9. Setup Funnels and Goals

Identify where people exit and enter the checkout process. There are two types of funnels we will setup to achieve clarity with user behavior during the checkout.


Complete this step by using my Shopify goal checkout template. Super quick. That uses regex and will include product pages. To setup your own funnel:

1. Go to your Google Analytics account, click “Admin”, select your filtered view then click “Goals”.

2. Create a new goal.

3. Select “Custom”. Personally I hate the templates because they vary in nearly every account I work in.

4. Name the goal “Checkout Complete” and select the “Destination” goal type.

5. Enter the goal details exactly like below. This is the standard checkout process for Shopify stores. The page URLs actually don’t exist, but the tracking setup done earlier has Shopify create virtual page view data for a consistent URL structure. Confirm “Equals to” is selected as the destination:

Google funnel for Shopify

Your funnel can be viewed in “Goals” > “Funnel Visualization”. The report is great because you can see how users enter and exit pages, and if there’s a particular page that causes a lot of drop-offs:

Funnel visualization for Shopify using goals

6. (Optional) You can add the “Cart” page as a step, which has the URL /cart. If you do this, set the “Required” option to “No” because people may skip the cart page (depending on your theme) causing these people to go unreported in the goal.

Product pages can also be reported in the funnel. Select “Regular expression” as the destination then use regex for the pages as shown in this screenshot.

The match type that you select for your goal URL also applies to the URLs in the funnel, if you create one.Destination goal examples from Analytics Help

Checkout Behavior Report

The second funnel we want to setup is the Checkout Behavior report in the “Conversions” section of Google Analytics. The report provides similar insight as the funnel we just setup with Goals, but it allows for easy segmentation through dimensions letting you see each stage of the checkout process for people in different countries, browser, traffic source, and more. It’s a killer report for conversion rate optimization.

1. Go to your Google Analytics account, click “Admin”, select your filtered view then click “Ecommerce Settings”.

2. Enter three funnels steps of “Contact Information”, “Shipping Method”, and “Payment Method”. These are labels used in the Checkout Behavior report. Your Ecommerce Settings should look like:

Checkout behavior report funnel configuration

3. In Shopify admin, go to “Online Store” then “Preferences”. In the “Additional Google Analytics JavaScript” section, paste the following code:

// Checkout steps for the Checkout Behavior report in Google Analytics from
var ShopifyCheckoutstep = Shopify.Checkout.step;
switch (ShopifyCheckoutstep) {
  case "contact_information":
    ga("require", "ec");
    ga("ec:setAction", "checkout", {
      "step": 1,
      "option": "contact_information"
    ga('send', 'event', 'checkout', 'contact information', { nonInteraction: true });
  case "shipping_method":
    ga("require", "ec");
    ga("ec:setAction", "checkout", {
      "step": 2,
      "option": "shipping_method"
    ga('send', 'event', 'checkout', 'shipping method', { nonInteraction: true });
  case "payment_method":
    ga("require", "ec");
    ga("ec:setAction", "checkout", {
      "step": 3,
      "option": "payment_method"
    ga('send', 'event', 'checkout', 'payment', { nonInteraction: true });

When data collects, your Checkout Behavior report will look like this… sweet sweet data:

Checkout behavior report for Shopify

We worked on this client’s funnel with an irresistible offer to have such a low drop-off rate throughout the checkout. Don’t expect your figures to look this positive.

4. (Optional) The Checkout Behavior setup so far is useful for all Shopify stores. The Checkout Behavior report is particularly powerful for Shopify Plus stores. Plus customers can add more steps to the funnel because of checkout customisation for deeper insight. Perhaps you have an upsell lightbox. Another idea to track is the individual fields at checkout to see where people get stuck.

To track additional checkout behaviors, you need further custom JavaScript or datalayer events inside your theme. Simo Ahava has a good guide to do so among many excellent technical guides on Google Analytics.

10. Use Enhanced Link Attribution

Enhanced link attribution is an extra layer of information Google gives you to visually see what people click on. You get to see how people interact with a page. I use it mostly on the home page, product pages, and other highly-viewed pages to see interactions with links. The data then lets you create hypothesis for split-tests, “Moving our brand collection in the header navigation to the first link may help people more quickly find what they want to increase sales.” or “This section gets less attention then we thought.”

1. In Shopify go to “Online Store” > “Preferences”.

2. Copy-and-paste the following line of code into the “Additional Google Analytics JavaScript” field of Shopify then save the page:

ga('require', 'linkid'); // Enhanced link attribution

3. Go to your Google Analytics account, click “Admin” then “Property Settings”.

4. Turn on “Use enhanced link attribution” then save.

Use enhanced link attribution

5. Use the official Chrome extension Page Analytics made by Google. Then browse your website like a normal user to see the fancy click data.

11. Fix Spam Hits

When someone visits your store, your analytics script gets loaded. This counts as a visit on your site. However, your analytics can load via Google’s Measurement Protocol without a person actually visiting your store. Bots can then send a variety of information into your analytics that reports on unusual things. You’re online with Google Analytics so I guarantee you face this issue.

The most common type of spam in analytics is referral spam. Another recent one is language spam. These are often sent by bots unscrupulously trying to promote a business or get a political message across.

Another problem. What if a competitor used your analytics ID on a fake page that automated hits to mess with you? Unwanted hit information distorts your aggregated data like page views, conversion rate, and page value.

View the referral traffic coming to your store at “Acquisition” > “Referrals”. You may see mentions of money and SEO-related websites. Some disguise themselves as major media outlets with domains like (notice the “l”) to trick you into visiting the page to look for the mention of your store. Others have malicious intent to distort your data.

A good way to identify referral spam is to look at your referrals in analytics then click on the “Avg. Session Duration” to filter by the column so “00:00:00” values are first:

Referral spam in Google Analytics

Unethical companies ping your Google Analytics script to achieve the hit they want on your website then “quickly leave”. You cannot eliminate the problem forever, but here is how to mitigate it:

1. Go to admin then “View Settings” for the profile you can edit.

2. Click to check “Exclude all hits from known bots and spiders” then save:

Exclude all hits from known bots and spiders

There’s few things I like Google to automatically handle, but the exclusion of known bots and spiders is reliable. You have another view to compare referral information to reassure yourself.

3. Create a new filter in the same view by going to “Filters” then “+ New Filter”.

4. Use a simple hostname filter for the domain name of the store.

Name the filter “Only Include Store Hostnames”. Select “Custom”, select “Include”, then select “Hostname” as the filter field. For your filter pattern, copy-and-paste the below:


The filter pattern uses regex.

Following the Shopify checkout domain migration from to the store’s primary domain on July 31, 2017, step five below is not required. I encourage you to do it though because the Shopify domain is still used in draft orders.

5. Are you a Shopify non-Plus member? You require an extra step. You cannot use the common practice of filtering spam hits based on hostname data because all /checkout pages get excluded. Vanessa from Shopify pointed out that Shopify uses virtual page views for the checkout pages, which means the URL you see in the address is different to what is pushed inside the analytics.

We have to create a filter with a custom field that combines the hostname and request URI. After that, create another filter that looks at this new field.

i) Name the filter “Custom Field 1 for Hostname Filter”. Select “Custom” then “Advanced”.

ii) For Field A select “Hostname” and enter (.*)

iii) For Field B select “Request URI” and enter (.*)

iv) Output to “Custom Field 1” and enter $A1$B1. Custom Field 1 is a way to store values for other filters.

v) Ensure the “Field A Required” is unchecked. The /checkout pages do not have hostname data.

Save it. Your filter will look like:

Custom field 1 Shopify hostname

v) Create another filter. Name the filter “Only Include Store and Shopify Checkout Hostnames”. Select “Custom”, select “Include”, then select “Custom Field 1” as the filter field. For your filter pattern, copy-and-paste the below:


Replace with the URL of your store. Don’t include the www part of it, use .* before and after, and escape any full stop with a /.

If your URL fails to redirect to your primary domain (you should configure it to redirect instead), you also need to include it in your filter.

Save it. Your filter will look like:

Include filter for Shopify

An alternative to consider is the following, which accommodates Google Web Light. The feature is sometimes offered to mobile users in search results when Google detects a slow internet connection:


To differentiate between stores that have similar domain stems like a “” and a “.com” domain, change the .com regex to exclude hostname visits. Use the [^] regex feature. If not, the .com.* portion of your filter will match the domain and include your traffic in the .com filter:


vi) Ensure your custom field filter has a rank with a lower number (so it comes earlier) then the filter that uses it otherwise you will get zero traffic:

Analytics filter order

6. (Optional) Are you really keen to eliminate all ghost referrals in your data? Create a new filter to eliminate these referrals. Select “Custom” for the “Filter Type”, and select “Exclude”. Enter the filter pattern field following regex rules. Wrap the URLs in brackets and separate each with a pipe. The full stop and asterisk means any domain that matches the pattern like gets excluded so be careful you don’t exclude a legitimate website. Here’s an example of one I setup for a client:


There is a github project that is updated with known referral spammers so check that out.

If you only include the store of your URL, you will exclude your YouTube channel when it’s linked with your analytics. If you have YouTube connected, add to your filters or other VPNs from legitimate users (like with such filters. Remember, you want to include any URL that contain your analytics ID. See the start of the cross-domain tracking section to identify what are these URLs.

12. Track Logged-In Users

Google signals tracks users logged into their Google account. This step is about tracking users logged into the store.

When you track logged-in users, you begin to calculate customer lifetime value, analyse where high-value customers come from, and remarket to your biggest customers from the moment of implementation. Most stores have historical customer data that presents remarketing opportunities not in analytics. You can import Shopify data into analytics for marketing purposes using Google Tag Manager, but that is beyond this guide.

When someone abandons checkout on their mobile phone and completes their order on desktop, the mobile session should be acknowledged for its assistance to optimise sales. The User ID in Google Analytics unifies any number of sessions for a logged in user.

The User ID tracking can be setup multiple ways in Shopify. I’ve worked a lot on this, been frustrated with several limitations that result in inaccurate data, and have come up with a beautiful method that works. I’ll describe the steps then what I’ve tried:

1. Go to admin then “Tracking Code” for the property. Click on “User-ID”.

2. Read and comply with Google’s User-ID policy and your laws. Google has strict privacy policies in place for the feature to obey laws so follow them. Don’t be ignorant and get your ass bit. Respect people’s privacy and what you may not know about it. Go to the next step.

3. Turn on “Session Unification”. If you have guest checkout in Shopify, this will bring a user’s session data into the User ID when it is created upon account registration. Go to the next step.

4. Create the User ID View:

User ID tracking in analytics

5. You will be asked to setup a new view. Name it something like “ – User ID View”. Select your time zone then create.

6. Mimic the settings from your “Filtered View” covered throughout this guide into your “User ID View”. The primary things you want is the enhanced ecommerce tracking, view filters, and view settings.

Google Analytics is ready to go. You just need to configure your Shopify.

7. This is where things can vary. Option one is to edit your theme.liquid file in Shopify. I don’t recommend this method for most people because users are unidentified on checkout pages for non-Plus stores. Place the following code before the closing head tag:

{% if %}<script>
  $(window).ready(function() {
    $('head script[async][src*="analytics"]').on('load', function() {
      ga('set', 'userId', '{{}}');
</script>{% endif %}

The script mostly works because it runs if the variable exists (stops the “Uncaught Reference Error: ga is not defined” error), the variable is inserted upon page load, and the jQuery code runs when the Shopify analytics library has loaded. If you just insert the ga(…); portion, you’d get an “Uncaught Reference Error”. If the store does not have a jQuery library, add:

{{ '//' | script_tag }}

It would be ideal to pass the ga ('set'...); line of code within the Additional Google Analytics JavaScript section of Shopify, but alas, that portion does not process liquid. I talked with three people involved in the analytics at Shopify until I was told liquid does not process in that section for security reasons.

A second option is:

var userId = ShopifyAnalytics.lib.user().anonymousId();
ga('set', 'userId', userId);

When Shopify ran its checkout on this did not work because anonymousId(); varied between your store and I am unsure if this is still the case following the checkout migration.

Option three is my recommended method. Use this line of code in the “Additional Google Analytics JavaScript” section:

if(__st["cid"]) ga('set', '&uid', __st["cid"]); // User ID tracking

Google say it is a best practice that “all subsequent pages in which the user is considered identified should also set this value.” If you log into a customer account, your userId will be set on every page. Use the GA Debug tool to see the variable’s value exists on normal and checkout pages:

userId in Shopify

If you’ve followed everything in this guide so far, your analytics section in Shopify will look like:

Additional Google Analytics Javascript8. View the various cross device reports under the “Audience” section of analytics:

9. An added secret to get even better user data is switching on the users metric in reporting. Google says, “You can use the User-ID feature in conjunction with the client ID to more accurately identify users across all the devices they use to access your site or app.” Go to the “Property Settings” then “enable users metric in reporting”.

13. Identify Organic Search Keywords

What search terms make your store appear in Google? How many clicks did you get last month from a specific search query? Where are you ranked for a search term? How many positions did you move up for your main keywords? All this can be gathered from Google Search Console, formerly known as Google Webmaster Tools. It is my favorite and recommended tool to monitor Google ranking data.

You can setup Google Search Console for Shopify and have it integrated in analytics to see organic performance.

1. Go to Google Search Console. Login or signup for an account.

2. Verify your store with Google Search Console by following the steps in my Google Shopping for Shopify book. I prefer to verify a store with the DNS method to avoid code in the header of pages that can be removed from theme edits plus you get the most comprehensive domain data in Search Console for SEO insights.

3. Go to Google Analytics. On the left-side, go to “Acquisition” > “Search Console”.

4. Follow the directions to enable Google Search Console in your analytics account.

Google may have up to 90 days of data on your store if you just setup Google Search Console. In the queries report, you will see all queries, their impressions, clicks, average position, and click-through rate. Here is a screenshot of organic performance from a Shopify client I do SEO for:

Google Search Console in analytics

14. Configure Third-Party Apps

Apps that change the checkout affect major business decisions by interfering with the tracking of sales. There are three primary third-party apps I see interfere with this Google Analytics setup. Each app has supported documentation for the right integration. Developers regularly change their apps so it is best you review what they advise. My comments include what adjustments are typically needed to make each app work well:

  1. ReCharge. You will need to setup a new Google goal to track the new checkout process. If you have subscriptions and want to attribute the traffic source of recurring purchases, setup the integration with LittleData. The LittleData app will provide most of the checks used in the article. The app makes use of various APIs and Google’s measurement protocol to send UTM parameter information for subscriptions.
  2. Bold Subscriptions. Add your analytics tracking ID and enable Enhanced Ecommerce.
  3. OneClickUpsell by Zipify. Zipify says, “Pages will use the built-in Google Analytics integration for Shopify by default to track statistics about your pages, but you do need to connect your GA account in the app to view stats, run split tests and view stats about how your split tests are performing.”

Due to the abundance of options, all checkout apps are not discussed. Additionally, there are other behaviors in apps you may want to track. For example, email marketing platform Klaviyo and popup app Justuno, let you track form signups. You can track almost anything you want with events.

I suggest you start by asking yourself what you want to optimize for. Most stores will never use form data to make a decision so there’s no point that they setup events for minute behaviors.

15. Get Custom Alerts

You’ve got a lot on your mind that you cannot check your analytics everyday yet alone do a deep analysis. You wear many hats, deal with customers, manage products, update social media, and often feel you cannot optimise your marketing to what it could be because of a lack of time. Shopify owners often come to me for help to save them the stress of growing their store.

You cannot be everywhere at once. Let’s say you’re sipping a tasty coffee at a cafe as you brainstorm a promotion. You get a text message that says your store has received no visitors for a day. You check your store then find out you forgot to renew your domain name! The custom alert stopped hundreds of dollars in further sales from being wasted and potentially someone else claiming your business. Phew.

Google Custom Alerts is one strategy to save you time and manage the marketing performance of your store. You can receive an email or SMS of major behavioral changes on your store. Learn when you get spikes in traffic from another website so you can check what’s said about you, if conversion rates for a traffic source drop to an undesirable percentage, or revenue changes from a country.

If you can see a type of data in analytics, an alert can be setup to track the data. To setup an alert:

1. Go to “Customization” then “Custom Alerts”.

2. Click “Manage custom alerts” then click “+ New Alert”.

I recommend you setup at minimum two alerts right now.

1: No daily traffic

Learn when your site is down. Configuration to use:

Name: No daily traffic
Period: Day
This applies to: All traffic
Alert me when: Sessions
Condition: is less than
Value: 1

The downfall of this is your store has to be down for a day before you’re notified. If your store churns over many daily sales, consider buying a Pingdom subscription for quicker notification.

Also consider a variation of this alert where the value is 50% of your daily traffic. This can hint that your store was down for most of the day or there was issues with paid advertising not driving the traffic it normally would. Test to see the notifications you get then adjust if it happens too often.

2: Revenue increase for new visitors

Learn when you get a nice boost in revenue from new visitors on the same day compared to the prior week. Thanks to Avinash for this alert. The configuration to use:

Name: Revenue increase for new visitors
Period: Day
This applies to: User Type
Condition: Matches exactly
Value: New Visitor
Alert me when: Revenue
Condition: % increases by more than
Value: 20.0%
Compared to: Same day in the previous week

The alert does not compare Sunday to another day but to the previous Sunday.

When you get the alert, use the “New Users” segment to dig into traffic sources, pages, and products that lead to the jump and select the weekly date range that compares the prior period:

Weekly new users segment

The alert helps you do more of what is performing well. Apply the condition “% decreases by more than” to see what under-performs.

3: Drop in performance of products

This is more of a custom alert to give you an idea of what is possible. The alert notifies you when any of your products have a bounce rate greater than 50% for a week:

Period: Week
This applies to: Page
Condition: Contains
Value: /products/
Alert me when: Bounce Rate
Condition: % increase by more than
Value: 50%
Compared to: Previous week

Product bounce rate alert

Google removed their pre-built alerts under the “Intelligence Events” section. You can get a broad sweep of automatic alerts from the “Automated Insights” report available in the Analytics app.

16. Ongoing Best Practices

Track Campaigns with UTM Parameters

Google Analytics automatically tracks a lot of your marketing like searches from Google or a link from Facebook. But what exact Facebook posts, Pinterest link, or offline promotion lead to sales?

URLs promoted in marketing materials not setup with the correct parameters manifest itself in the abyss of “Direct” traffic. When you view your “Acquisition” report, you will see a “Direct” traffic source:

Direct traffic source Google Analytics fix

A large percentage of direct traffic for your store will come from not using the UTM parameters explained here, apps, or visits from a https page to a http page. Any time you can control the URL of your website in promotions, even offline, you can track the profitability of each campaign with UTM parameters. It is unnecessary to manually add UTM parameters if you have auto-tagging enabled in your Google Analytics link for Google Ads.

You must use UTMs for all marketing campaigns if you are serious about growing your store. Do what you can to minimise direct traffic sources because it provides no insight into performance.

The Digital Darts’ Google Campaign URL Builder lets you add the required UTM parameters to any link so direct traffic that can be tracked is reduced. You can even track offline print by creating a short URL like then 301 redirect the page with the parameters from the tool. I built the tool so you can bookmark it for any marketing campaign.

The only difficulty is being consistent with UTM parameters. You want to be able to look at the variables and understand what each campaign references. Instead of using your regular product link in an email campaign, the link would look something like:

Consider creating a spreadsheet to track your campaigns. Also establish best practices for your stores like “use all lower case in the variables”, “include dates formatted dd-mm-yy in the campaign source variable”, and “use hyphens for spaces”. Refer to Google’s documentation for more help.

You can view the performance of your campaigns at “Acquisition” > “Campaigns” > “All Campaigns”.

Annotate Major Changes

An annotation is a time-relevant comment you insert into Google Analytics below most line graphs. Annotate changes to analytics. When you analyse and report in the future, you have possible explanations for unusual data changes. “Why did our time on site increase and user sessions decrease? Oh, I see in the annotation we blocked referral spam.” If you are actively involved in your marketing, take advantage of the feature by annotating major marketing events like the day you got a mention by an Instagram influencer or a spam warning by Google Search Console.

Analytics annotations

Exclude Active Team Members

People who regularly work on the store will distort data. Distortion is amplified if the store’s traffic is small or the person uses the store a lot. You want to exclude your agencies, partners, or employees who may regularly visit the store. You can go overboard for no benefit, so focus on those who regularly work with you.

You exclude people from distorting Google Analytics data with their IP address. The method works great for static IP addresses. Unfortunately, most IP addresses are dynamic. I think dynamic IPs are not worth excluding.

Google search “IP address” to discover yours. (If you do the search again in a week or two, and the number is different, it is dynamic.) Inside your Google Analytics, go to “Admin”, select a non-raw view you want clean data on, and click “Filters”.

Google Analytics filter IP address

Create a new filter. Name the filter whatever you want like “My IP Address Exclusion”. Select “Custom”, “Exclude”, “IP Address from the drop down, and type your IP address in the “Filter Pattern” field. Save it.

17. Report and Analyse

What you learned in the The Finest Google Analytics Setup in Shopify for Splendid Data is data collection (and a tiny bit of reporting and analysis).

Complete profitable analytics work involves the three-step process of:

Data collection > Data reporting > Data analysisAvinash Kaushik

The four areas to get good comfortable with data reporting and data analysis are primary dimensions, secondary dimensions, segments, and custom reports to extract the data you need for growth.

Any report is useless unless you start asking yourself questions. From questions come hypothesis that you can explore with particular reports and analysis. Do not mindlessly click around looking at numbers.

18. How to Review the Results and Get Help

Give what you’ve done 24 hours and a few sales to take place. The time will allow data to gather then be reported.

There are two reports in your filtered views that show the most important data from this tutorial. Firstly, look at your channels report. Here’s one client of mine that shows sales are tracking through various channels:

Need help referral source

A broken setup will either have most sales come from referrals or show inaccurate revenue data.

The second report is the shopping behavior report, which should show full data:

However, should these reports reflect the number of transactions you’re seeing in Shopify, it does not mean everything is setup right. These two inspections do not cover the checklist in the tutorial, but are broad benchmarks of what matters most: sales, the source of sales, and checkout behavior (because it’s related to enhanced ecommerce). There are hundreds of ways you can get your analytics setup wrong.

If you are worried about what you did or you want other custom work done, let us save you. We can set up everything in this guide for you and more.

Have Google Analytics in your Shopify store work beautifully with no effort on your part so you can get on with growing your store. We will have everything in this tutorial working for you within one week for an investment of AU$997. For another AU$300, you’ll get my best custom analytics reports to see the data revealing strengths and weaknesses of your content strategy, page load times, organic SEO, Google Ads, product performance, collections performance, and more, so you can grow the store. Contact us to discuss.

COMMENTS: Commenting has been disabled due to the large number of comments on the article with requests for help. It is impossible to provide answers without a detailed background and spending time doing a consultation to investigate.

Liked this article? Get more free Shopify guides:

Related Posts


  • Great article, thanks for the step-by-step guide!

  • Splendid stuff. Very helpful guide even for a Shopify veteran. Now, looking for the same for dynamic remarketing as well as pushing data to the data layer to be able to target cart abandoners by value and other segments too.

    • Thanks Yotam. I have just updated the analytics guide based on my discussions with Shopify after I found out page views were being excluded in section “9. Fix Spam Hits” because of a hostname filter.

      Checkout the AdRoll app for dynamic remarketing. What you’re wanting to do is doable.

  • Thank you so much for this how to guide! I have been updating our GA and Adwords set up based on both of your awesome guides. I did have a question that maybe you could help me with as the people over at Shopify do not seem to know what happened. We finally got conversions tracking in Analytics using the URL: /checkout/thank_you per Shopify’s instructions and it worked for one day. However it just stopped working. Now we do have ecommerce tracking perfectly (and it has been since day one) so we have that info however it would be nice to get goal tracking working properly. Any advice as to what may have happened?

  • More info – when we verify the goal set up it gives us this message: “This Goal would have a 0% conversion rate based on your data from the past 7 days. Try a different setup.” Although in the last 7 days we did have 95 recorded goals (well only few hours last Wednesday when it was working)

    • Well after going thru your instructions again I see where the error was (my user error). I did the Custom Field 1 for Hostname Filter after I set up the conversion and did not uncheck Field A required so since the check out has not hostname it was blocking all goal conversions. Anyways, this was an amazing tutorial. Sorry for my 3 posts. Keep up the good work! Looking forward to your next one.

  • The guide has been updated to include User ID tracking.

    • Thanks for the great article. Can you let me know if I can get cross-device conversation data/information to fine tune my adwords campaigns. I do not have user accounts enabled and do not plan do it either. Is it possible to set this up or it is not possible?

  • Thanks for the great article Joshua, what a top man!

    Regarding your points on Tracking Sub-domains,
    What will be the best practice for the people who has their Shopify store set up on subdomains and WordPress content blog on www?

    Thanks again Joshua!

  • Holy moly! I missed a lot of things while implementation.

    This will be my checklist when I open a new store on the shopify.

    Thanks Joshua.

  • Hi Joshua,

    You mention that “A funnel or goal alters the “Checkout Behavior” report in “Shopping Analysis” of Google Analytics.” How does this work?

    Unfortunately I can’t see the numerous steps of the checkout process within this report. All I see are step one and ‘sessions with transactions.’ Is there a way that I can edit this report to include all of the checkout steps or is a seperate goal and funnel required?

  • This Guide has been really helpful Josh. It’ll be great if you can publish something on how to create effective Reports and Dashboards. Getting this data together is great, but I think most of Shopify Store owners are still dependent on using the Shopify admin Dashboards only because of the convenience it offers. An article telling us how to start using Google’s dashboards and reports would be fantastic!

  • Avatar for Russell Smith
    Russell Smith
    March 19, 2016 5:06 pm

    Hi Josh,

    Have you ever come across this error when trying to set up In Page Analytics?

    “Access denied. Please try relaunching In-Page Analytics from the report.[Error: 20010]”

    Everything else seems to be set up correctly, just this displays when I go to full screen mode. Thanks!

    Awesome blog by the way. Going through it step by step.

    • Russell, I’ve had that error for as many years as I can remember. Happens whenever I launch the in-page analytics of G Analytics or load it in full view. Recommend you use the Page Analytics (by Google) Chrome extension. Works well.

      • Avatar for Russell Smith
        Russell Smith
        March 22, 2016 11:57 pm

        Hi Joshua,

        So confused. But very grateful!

        I did have the extension installed, but it wasn’t working. Due to your encouragement, I removed it, then re-installed it.

        The story doesn’t end there – as it would ONLY work for my own sites (wordpress) and told me my client sites (Shopify) were not accessible by me (wrong Google account, tracking code not found etc).

        Then it just started working.

        OK! Not gonna argue with that. Seems the in-page analytics function is a little sensitive.

        Anyway, massive appreciation for your blog and for helping me out with this.

        Thanks! – Russ

  • Basic question – this works when shopify is your main domain but does the same apply if the top-level is a wordpress site and the subdomain is shopify? (wordpress) (shopify)


  • Avatar for Russell Smith
    Russell Smith
    April 5, 2016 11:46 pm

    Hi Joshua,

    Should ‘add to carts’, ‘remove from carts’, ‘cart-to-detail’ and ‘buy-to-detail’ in ‘Product Performance -> Shopping Behavior’ be working with this set up?

    Mine is not tracking. The rest seems to be OK, except ‘Shopping Analysis -> Checkout Behavior’, which only shows ‘Step 1’ and ‘Sessions with Transactions’.

    It’s not a good cart analysis.

    Is it because I’m not with Shopify Plus? Or should this stuff be tracking?

    Thanks! 🙂

    • Works for all versions of Shopify.

      • Avatar for Russell Smith
        Russell Smith
        April 6, 2016 2:16 pm

        Hmm. Thanks.

        So have you ever heard of the ‘add to carts’, ‘remove from carts’, ‘cart-to-detail’ and ‘buy-to-detail’ in ‘Product Performance -> Shopping Behavior’ not tracking? Everything else seems to be fine.

        I’ve checked ‘site content’ -> all pages (secondary ‘hostname’) and all my cart pages have tracking on them.

        This is how it looks:

        I can’t find anything on Google about this. And I’m confused by your comment on section 3 (setting up enhanced ecommerce) where you mention:

        “Shopify Plus stores can setup events then see things like the checkout behavior of people who login, if people abandon cart at the shipping option, and generally the fields people get stuck on the payment page.”

        So I’m thinking maybe those things actually won’t report for me on the basic Shopify setup.

        I appreciate you taking your time with this, the content here is excellent!

        Thanks – Russ

        PS. This is the store:

        • Read the paragraph before and after that, Russell. Only Plus stores can track more in-depth, the fields and pages on the checkout process reported in the checkout behavior. Everyone if they want can create other funnels as long as it’s on their own domain.

          Debug by finding the event that is suppose to trigger for the “Product Adds to Cart” and seeing what analytics data is passed or missing when you add to cart.

          • Avatar for Russell Smith
            Russell Smith
            April 13, 2016 1:50 pm

            Thanks Joshua, sorry for the confusion!

            Appreciate your help 🙂

            – Russ

  • Hey Joshua,

    Great Article ! very well done – just curious if you have explored using the linker plugin for google analytics – instead of adding sub domain traffic with custom filters ?

    I have a set up with ( as the main site ) and as my Shopify store – and I want all the tracking data under one view so I can see how sales go from an Advertisement click > to the main site > to the sub domain shop

    Linker script set up :
    ga(‘require’, ‘linkid’);
    ga(‘create’, ‘UA-******-6’, ‘auto’, {allowLinker: true});
    ga(‘require’, ‘linker’);
    ga(‘linker:autoLink’, [‘’, ‘’]);

    The data seems to be tracking as I would like / as it were all one domain – and with some tips from your article above I am pretty happy with the set up.

    Just wondering if you know of any downside to using the linker plugin VS the filters for sub domain traffic ?

    • You shouldn’t say “the linker plugin vs the filters”. They are entirely different things. The linker plugin can provide the analytics code basis for cross-domain tracking between domains. The filters just alter the reporting in your analytics view. I’ll update the guide soon with the right allowLinker code in the sub-domain tracking section. You don’t need to include in your autolink code because this analytics snippet is only on the main site.

      EDIT: The sub-domain tracking section in section 5 is updated with the correct code.

  • Hi Joshua,

    Thanks so much for writing such a detailed and awesome guide. It’s been a life-saver for me. I have just one question: is it possible to track events with Shopify? I have researched and found nothing. I’m interested in tracking things like social shares, add to cart clicks, 404 errors, and a few other things. Even though I have found a nice tool ( that allows me to create events easily, the thing is, where do I install them? And the most important question, is it possible to do so?

    If you have any idea, or if you could point me to the right direction I’d higly appreciate it.


  • Great article that’s got my analytics set up properly.

    Now the question is how to read the data…. Another article int he pipeline Joshua?


    One slight tweak the code I think now should be:

    {% if %}ga(‘set’, ‘userId’, ‘{{}}’);{% endif %}

  • Hi I need help, I followed step by step the 16 steps and now my google analytics stop receiving data. like since the day I completed the steps I have recollected 0 data. Can you help me?

  • When I activate enhanced ecommerce do I have to turn off normal ecommerce tracking?

  • Epic article! Very much appreciate you sharing the info! 🙂

  • I have some question still;

    Enable user id feature; I got as far as creating – User ID View but i didnt quite get what you meant by;
    6. Mimic the settings from your “Filtered View” covered throughout this guide into your “User ID View”. The primary things you want is the enhanced ecommerce tracking, view filters, and view settings (most importantly “Site search tracking”).
    Do you mean i have to create all the filters, goals for this view as well? If so, is there no copy feature i mean thats a hell of a lot of work.

    8. Funnels and Goals – here you say use my regex then ask us to create another one. So that means i now have 2 called checkout completed is that correct?
    8. Funnels and Goals – You tell us to look at Goal > Funnel visualization. There is no such option Funnel Visualization, well at least i dont see it anywhere.

    At thee top of the document you say, Have one original view. which view is that? Is that the second one created for user id tracking or does that mean create a 3rd one.


  • Thanks for this great tutorial. I found that for Product content grouping it’s better to use

    And remove /collections/ from the beginning because in some cases users might land on a product page directly from catalogue or a link or from search, and including /collections/ at the beginning will cause those hits not to get tracked.

  • Great guide – thank you very much for this!
    Quick question about properties: Should the same one be used when using two different sites?

    For example, if I have created UA-xxxxxxxx-3 to use on my main root site which is wordpress ( should I used the same property when hooking up Shopify on subdomain (

  • Hi Joshua,

    Fantastic writeup.

    Another item to add here (although minor) is to fix the Ecommerce Product Performance reports. By default, Shopify includes variant data in the product name, forcing you to a per-variant granularity level in your reports. The fix is to export your products from shopify and re-import in Analytics using the custom data import tool.

    A full writeup on the process is here:

    Hope this helps.



  • This guide is awesome. Just helped me polish up some settings in GA and Shopify. Well done!

  • Great and easy guide to follow. Was very educational too!

    Thank you

  • Wow. This is such a comprehensive and value-packed article Joshua. I don’t think I’ve ever seen anything like it. Learnt a lot but am having trouble setting it up. GA says I’m set up for eCommerce but no data is flowing. Thought it was as simple as turning on the switch (as seen in your example above) but apparently not. Unfortunately both Shopify support and the theme developer have just asked me to look at some GA article that had my brain in knots. ;(

  • Hi Joshua,
    Very concise guide. Thank you.

    I wonder if you could explain how to limit remove shipping and taxes from being counted in total revenue in GA enhanced ecommerce.


    • Hi Dave,

      You might be able to do something like that with, but without knowing your why, I’m guessing you are asking the wrong question. Review and work with product level data. For example, the product performance report will tell you the product revenue which is the revenue you want to know. If there’s missing figures or deeper analysis you want to do, then create custom reports or segment with the fields.

  • Hi Joshua, Great post. I would like to create a goal for my contact page submission. Would you know the code for that one? Is it using onsubmit?

    • Sorry for the late reply Bryan. Missed your comment. The easiest way to track most contact page submissions in Shopify is with a destination goal that contains something unique in the URL once the form is submitted. It depends on how your form is built. Some forms use ajax and do not take the user to a new URL, in which case a custom event needs to be added to the code to trigger the goal.

  • Hi Joshua,

    Great article, helps a lot, thank you!

    Question – is it possible to add user ID tracking code to Additional Google Analytics Javascript field if Enhance Link contribution code is already there? Can these scripts co -exist?

    ga(‘require’, ‘linkid’);
    ga(‘set’, ‘userId’, {{USER_ID}}); // Set the user ID using signed-in user_id.


  • Awesome guide. Thanks so much! However, I experience one problem. For some reason no Ecommerce data was captured with this setup. I found out that the reason is the two anti-spam filter I setup according to your guide. I am a Shopify non-Plus member and have setup the two filters you recommended and used exactly the same patterns and settings as in your screenshots. I have removed the filters and it works now.

  • Great article man! Cheers.
    For those with no eCommerce data flowing, removing the analytics code from Shopify, saving, and then re-adding it might do the trick. (you can also reset enhanced eCommerce in GA) Helped me with 2 stores having no ecom data flowing.

  • Hey Josh, My Adwords campaigns are now showing as “not set” in the new filtered view but they are still there on the unfiltered view. Any idea which setting may be causing this?

    • AdWords linking is done at the property level so that is unlikely to be the issue. Given you have the unfiltered view which is recommended for diagnosing issues like these, it could be a filter issue.

  • Thanks so much for the wonderfully in-depth article. A quick question 4 u . . .
    In creating a funnel for “completed checkouts”, you set the destination url as equal to “/checkout/thank_you”. However, the actual url for a checkout contains the string “checkouts”, not “checkout” (i.e. – . ./checkouts/. . ./thank_you). So, wouldn’t the destination be “/checkouts/thank_you” (i.e. – use “checkouts” rather than “checkout”)?
    Thank you for your time, much appreciated!

    • The page URL pushed into analytics uses “virtual” information. This is mentioned in the guide. Look at the pages viewed on your site then from the secondary dimension, select hostname. Look at the hostnames and you will see the URLs used.

  • Hi Joshua:

    Thank you for this great guide. Appreciate it.
    I followed all the steps you mentioned here but I found out that my google analytics is not fire at pages like Customer Information, Shipping method and Payment method. But it did fired at Page View, Viewed Product and Add to cart page. Hence, my Goals Funnel stopped showing data after the Cart funnel.
    Can you please help me on this?

    Thank you

  • Hi Joshua. THANK YOU for this post. Super helpful. Especially to combat all the recent GA referrer spam…
    One thing — in step 9. Use Enhanced Link Attribution – adding
    ga(‘require’, ‘linkid’);
    to the GA additional scripts kills the Pay with Amazon button in checkout.
    If I remove ga(‘require’, ‘linkid’); – PwA works fine.
    With it, it’s a dead button. So I removed it.
    Anyone else notice this?

    • What’s your store Jeremy? I can have a look. I have never heard of analytics plugins conflicting with other scripts in Shopify.

      • Hi Joshua – instead of placing ga(‘require’, ‘linkid’); in the “Additional Google Analytics Javascript” — I placed it with the core ga script – just below:
        ga(‘send’, ‘pageview’);
        ga(‘require’, ‘linkid’);

        and that seemed to solve this (pay with amazon now works fine)
        Although it now appears that google is phasing out “In-Page Analytics” in GA, and sending us to a chrome extension for the data.
        So is linkid still important going forward?

        Unrelated / or maybe related—
        … are you aware of the “Trekkie” script that Shopify places and how Shopify appears to override whatever you place in the core GA script – they grab your property ID — but if you modify the script, such as inserting {‘siteSpeedSampleRate’: 100} into the ga create line, Trekkie seems to do its own thing. Anything you can share re: ‘Trekkie’?


        • Jeremy, what do you mean you placed it in the “core ga script”?

          I still use linkid as a way to capture extra data for things like conversion optimization. It’s another way to gauge user engagement on a page, though reviewing the data has always been buggy/annoying.

          I have not tried before to modify the information like “siteSpeedSampleRate” that is passed inside Trekkie. If you’re desperate to modify that value, as an idea, you could test using it with the standard UA code for a new tracking ID. It seems more effective than doing with GTM Watch for any changes in pageview and other data in your primary ID.

  • In November, a lot of “Russian websites” like and began to spam analytics accounts Worldwide. In the language settings of your analytics traffic, you’ll see a message like “Secret.ɢ You are invited! Enter only with this ticket URL. Copy it. Vote for Trump!” Notice the unusual “G”. One solution for this is to create a regex filter that excludes traffic with obscure characters in the language settings. My recommended solution is create an exclusion filter of “Language Settings” for hits that violate the standard language-country code. Use this as your filter pattern

  • Hi Joshua

    Brilliant walk-through thanks.

    One quick code question: We want to set up cross-domain tracking for more than one additional domain.

    The code snippet you suggest adding for one domain is:
    ga(‘linker:autoLink’, [/^.*yourdomain\.com$/]);
    Whereas Google’s support docs give this rather different syntax example for multiple domains:
    ga(‘linker:autoLink’, [‘’, ‘’] );

    (note: no dollar signs or slashes within the square brackets).

    Would you mind confirming what the correct syntax should be for the line we put into the ‘Additional Google Analytics Javascript’ box?

    Thanks – Jon

  • Hi Joshua

    Very nice tutorial! I have spread it under a large facebook community. I do have 1 question: After installing the Ecommerce tracking on 1 store it only counted 1 day for E-commerce -> Product performance.

    Do you have any idea why?


    • Hi Bob, thanks for sharing. Look at your unfiltered view first to begin diagnosing issues. Filters are the most common issue when people who haven’t used them before, start.

  • Hey Joshua,

    Want to clue you in on some confusion I had with the instructions above… Specifically with filtering hostname data via regexps.

    I was using (per the instructions in black background):


    in the Google Analytics filter. This ended up breaking the analytics capture.

    I found that we should use something more along these lines:


    That seems to catch all the possible permutations of hostnames (,,,, etc) for Google Analytics. I am NOT a regexp expert, but fumbled through it.

    Let me know if I am overcomplicating it.

    • Hi Thomas,

      The guide does immediately say after the section to “Replace ‘’ with the URL of your store. Don’t include the www part of it, use .* before and after, and escape any full stop with a backslash.” This is also shown in the screenshot. Even so, I updated the example.

  • Mine stopped e-mailing out the results to me after about 4 months. What’s the fix? Thank you for this wonderful script.

  • Think I found a typo in section 10.4.b.v. It reads “v) Create another filter. Name the filter “Only Include Store and Shopify Checkout Hostnames”. Select “Custom”, select “Include”, then select “Hostname” as the filter field.”

    Shouldn’t the filter field be “Custom Field 1” as shown in the screenshot?

    Really appreciate the depth and breadth of this resource. Thank you!

  • Great write up. This is super helpful for people who are working on ecommerce websites. I remember the first shopify site I worked on, it wasn’t as pleasant as reading this post 😉

  • I don’t usually do this but this tutorial was amazing, it took ma 1 hour + to get it right but I’m glad I did and wanted to say thank you.

  • Hello Joshua,
    I have a shopify store and I have Google analytics installed on it. I track test visits in real time from Adwords ads into my site and all looks good and the source of traffic is showing as google/cpc. Once I go to, source of traffic starts to show as direct traffic. I put shopy in referral exclusion list. is this enough? will I be able to track conversions from Adwords or will it show as Direct traffic conversion?

  • Avatar for Tom Blackburn
    Tom Blackburn
    March 13, 2017 6:29 am

    When creating the -2 or -3 google analytics tracking code, do I include those (-2 tracking codes) into the shopify GA or leave it as -1.

  • Absolutely fantastic tutorial. I think I might have done something wrong though – my filtered view shows no traffic today, my unfiltered view shows traffic. It’s not all me either, I know others have been going to the site. Any advice?

  • Hey, first thanks a lot for this crazy tutorial!! I just don’t understand the “Have One Original View” part, could you explain it a little bit more please 🙂

  • Hey Joshua,
    Thanks for the great tutorial. I’ve been using GA for a while and still picked up some good tips. I’m curious if you’ve run into issues with Shopify + GA where order values display in Ecommerce reports, but don’t display for any “Goal Value.” So, for example I’ll see 8 for “Goal Completions,” but $0.00 for Goal Value. Then, in Ecommerce reports I’ll see 8 orders and $399.92 in sales value.

    FYI, I’m using a “/checkout/thank_you” goal (like you’ve described in the post) and I’ve got the “Value” field toggled to “Off.” It’s frustrating that the goals don’t show monetary value b/c I want to link the checkout goal to Adwords and use it as my conversion metric. But, without order value the conversions aren’t nearly as helpful for Adwords bidding purposes since I don’t have a rough idea of LTV by Kw. I tried installing the Adwords conversion script in Shopify, but didn’t have much luck with that either. Made some test orders via Adwords ad clicks, but the conversions never showed back in Adwords reporting.

    I thought “filters” might be an issue here (since you mentioned that several times), but I’m still seeing the same goal problems (i.e. no monetary value) on both my filtered and unfiltered profiles.

    Any tips/thoughts you’ve got would be greatly appreciated.

    • Hi Garret, the same here! I wonder if you found out a solution already?
      As I know we must use cross domain tracking for this, but the second domain which is shopify domain, cant be managed by us :(, so dont know what else is the solution.

  • High Under setting Up content group setting what would be the expression rule for the
    Checkout Pages, Account Pages, 404 Errors, &Support Pages?

  • I was going along step by step and I really didnt know what this meant; how would I implement this? “The match type that you select for your goal URL also applies to the URLs in the funnel, if you create one.”

    Thanks for your help btw

  • Due to the popularity of this guide, please understand I cannot answer questions if you’re having problems. I have services to help stores in this area. There is plenty of advice in the article to help you diagnose issues.

  • Hey Joshua,
    This is a great post.
    Please Help my analytic is not tracking goals, I implemented all above mentioned tips and tricks. The only message i got “This Goal would have a 0% conversion rate based on your data from the past 7 days. Try a different setup.” We did have 140+ form submissions. Analytics is showing nothing. Please Help !!!


  • Really Really Really awesome article. Thanks for all the effort!



  • Hello, thanks a lot for your extensive explanation.
    My situation is a little bit different, as far as I have read and understood, I couldn’t find the answer in the content.
    Joe F

    1w – last edited

    I use Google Adwowrds and Analytics, Shopify for my website, when I check, as the main source of sessions, is shown paid searches (adwords), number of sales and number of conversions in Adwords are more or less in positive correlation, but Google Analytic shows that most of the referrals for purchases from my own website, paypal and shopify.
    There are two possible reasons for this in my situation. Cross Domain Tracking and Page Dropping Cookie.
    Regarding Cross Domain Tracking, I use single domain, but after the customer checks out, the Thank You page comes with Shopify domain, can it be considered that I use multiple domain? If yes, how can I solve it?
    In the link above, Google says that I need to write tracking code for secondary domain, so that code should be copied and pasted in each page of secondary domain, but if it is Shopify or PayPal, how can I do it?

  • Hey Joshua,

    This is a great guide. The best I could find related to Shopify.
    Thanks to you, we’ve almost corrected all the flows in our Analytics account.

    There’s only one thing I can’t get to work properly…
    Under Acquisition > Adwords > Campaigns : Conversions and revenue for Ecommerce are not showing up.
    I’ve tried everything, conversions are showing up correctly in Adwords
    On Analytics, under Conversion > Ecommerce > Sales Performance, I get all orders registered properly with their order ID.
    Adwords and analytics are linked of course…
    And no way to get the revenues generated for each keyword.

    I’m probably missing something very simple, but I’d be very grateful you have any idea.
    (We’ll be looking for an Adwords/FB ads agency very soon, but I want a few weeks of clean data on what we already have so we can start with reliable information).


  • Avatar for Chris McCreery
    Chris McCreery
    June 2, 2017 5:10 am

    Any tips on adding the Checkout Labelling used by Enhanced Ecommerce? I noticed that Shopify support says they don’t implement that.

  • Such a great guide. I just had trouble this the end of section 7:

    Google say it is a best practice that “all subsequent pages in which the user is considered identified should also set this value.” If you log into a customer account, your userId will be set on every page. Use the GA Debug tool to see the variable’s value exists on normal pages, pages, and the thank you page:

    Can you expound on that a bit? I’m not sure I understand the instruction.


  • Thanks for the comprehensive guide! One small but significant typo under “10. Fix Spam Hits – v) Create another filter etc.” the code snippet (highlighted with yellow background) is missing \ before /checkout


    and in the image preview it’s there as it should be.

  • SUPER GREAT Guide! I was wondering now that Shopify lets visitors checkout on your store domain has anything changed? (Mainly the different spam hits filters for plus / non-plus members)

    Thanks alot!

  • Silly question -> is supposed to mean my main domain? In my case that would be – in the same way that ‘’ would be ‘’ in my case. Thanks!

  • Following the Shopify checkout domain migration did the checkout funnel change and even the THANK YOU page? Right now I’m seeing:


  • Hi
    My understanding is we no longer need to add the snippet to google analytics on Shopify Preferences unless using display network – google ads – but just the UA Account ID

    • I don’t know what snippet you’re referring to. You’ve never had to add the following, which is mentioned in the guide, because Shopify includes the plugin automatically when setting up GA.
      ga(‘require’, ‘displayfeatures’);

  • Question on section 10 part 5, do we really need to create the Custom Field? Couldn’t we just include shopify as an allowed hostname (editing section 10 part 4)?


    • Nope. This is made clear:

      You cannot use the common practice of filtering spam hits based on hostname data because all /checkout pages get excluded. Vanessa from Shopify pointed out that Shopify uses virtual page views for the checkout pages, which means the URL you see in the address is different to what is pushed inside the analytics.

  • What a great guide – thank you!
    I set up checkout goal funnel yesterday. The goal verified, see goal CR on chart since yesterday. But Funnel Visualization is showing all zeroes. Any ideas?

  • Hey Joshua,

    Great article man. I have a question about passing Analytics custom dimensions into Shopify for the purposes of remarketing. I’ve already added AdWords remarketing tags with no problem, however I’m really looking to go a step further and build dynamic remarketing audiences with Analytics since the consensus is that these are more reliable to use for AdWords campaigns.

    I’ve read a number of articles that suggest to load Analytics custom dimensions asynchronously before the closing tag. The most common implementation I see referenced is this:

    ga(‘set’, ‘dimension1’, ‘shopify_US{{}}_{{}}’);
    ga(‘set’, ‘dimension2’, ‘{{template}}’);
    ga(‘set’, ‘dimension3’, ‘{{product.price_min|money_without_currency}}’);

    …however, doing this spits out a Console error: “Uncaught ReferenceError: ga is not defined”.
    …and more importantly, both AdWords and Tag Assistant cannot detect the Analytics remarketing snippet.

    You listed above under the ‘User-ID’ section that there’s an issue with adding Liquid code to the ‘Additional Google Analytics Javascript’ box, and yet, custom dimensions cannot just be added asynchronously with tags.

    Do you have any suggestions on how to implement this, even as a workaround?

    Thanks in advance, you’re the best!

  • My Shopify Analytics flat-lined on October 8th, and I’ve been trying to determine the source of the problem. I’ve followed this thorough Digital Darts’ post and also Ahmad Kanani’s step-by-step guide at Siavak to see if I missed something.

    Shopify’s tech support notified me today that they no longer support Analytics for under $300/month accounts (ShopifyPlus, A.K.A. most of us).

    What seems to happen is when you paste the new gtag.js code into Shopify’s preference page box for Analytics, their back-end editor, called TinyMCE from what I’ve gathered, strips off the remaining code after the first script close tag, leaving an unclosed script tag. I can’t find a way to implement or even generate legacy code, so Shopify has effectively dropped support for Analytics with no announcement. Basically, if you have no metrics, you can’t advertise, and if you can’t advertise, you aren’t going to sell much.

    I added the gtag.js to the header of my template.liquid file, but Shopify tech support suggested that I remove it.

    This is from Keith at Shopify tech support:

    “It’s likely we will migrate to gtag.js in the future depending on how it progresses but for the time being gtag.js scripts would not be recommended for use with a Shopify (excluding stores on Shopify Plus who choose to work with it)”

    • Look at the old style of analytics code as per the guide and use that, rather than the gtag solution. It will work fine. You just have to swap out your tracking ID.

      Shopify will have to migrate their analytics for gtag and sort out a bunch of other things for this new implementation in a few months. I believe Google is unifying their tracking code methods to use gtag in preparation for the public release of Google Attribution. Given the gtag is now standard in analytics, they are going to get a growing number of such requests from merchants.

  • Hi, Joshua.
    Great great tutorial!

    A quick question…should I add on my Referral Exclusion List?

  • Hi, Joshua.

    I think I have something to add to your number 10.
    For now, I just know one way to the customer reach* and it’s through View Order from the email. This is why I don’t like to ad this page on referral exclusion list, now that the checkout process doesn’t happen in Don’t you agree with me?
    So, when I did the number 10, I ended up creating 3 filters instead of 2 filters. I think it’s going to be nice if you tell explicitly that if someone wants to do the step 5, they need to remove the filter created in step 4, because this filter, the one created in step 4, exclude traffic in* I saw too later your last print(right before step 6) =/
    One more thing! The last filter created in step 5 still exclude the traffic in*
    The regex of the last filter, “Only Include Store and Shopify Checkout Hostnames” as you asked for naming it, should be: .*yourstore\.com*|checkout.*
    The regex can’t be .**|/checkout as it is in the item v)
    The regex can’t be .*yourstore\.com.*|\/checkout.* as it is in the print of item v)

    I’m sure that putting the regex as *yourstore\.com*|checkout.* includes the traffic in*, but I’m not sure if this regex includes the pages in the checkout process. Shopify still uses virtual pages on the checkout process, now under the domain of the store. With this regex *yourstore\.com*|checkout.* , I’m able to see myself on real-time in all pages, including the ones of the checkout (and on pages on*). I tested. But my concern is if what vanessa said about the virtual pages, that they don’t have hostname. If they really don’t have, this regex *yourstore\.com*|checkout.* will definitely exclude the traffic on the checkout process and a question will remains, why I’m able to see myself on real-time in all pages of the checkout process? For now, so that there’s no problem, i’m using the follow regex:


    Joshua, what are your thoughts on it? Thanks in advance and sorry, English isn’t my first language.

    • Hi Caio,

      I suggest tagging the view order email with UTM parameters. That way the traffic gets an attribution source. The should be in the referral exclusion list because it is not the origin of the traffic source – the email is.

      *yourstore\.com*|checkout.* is incorrect regex because there is no full stop like .* to match any character any number of times. Step 5 is not wrong. Run the analytics debugger extension and you will see the variable &dp has the forward slash like /checkout/… for checkout page views. This setup is in use by thousands of Shopify stores.

  • Hi Joshua,

    You mention this snippet of code under “Track Logged In Users (Option 3)”:
    if(__st[“cid”]) ga(‘set’, ‘&uid’, __st[“cid”]);
    This code is for ga.js. What is the new code for gtag.js?

  • Hi could you explain this part more in details

    vi) Ensure your custom field filter has a rank with a lower number (so it comes earlier) then the filter that uses it otherwise you will get zero traffic:

    i am afraid of getting zero traffic this the only part of the guide that was not clear to me thanks

  • Hi really awesome guide thank you, question though when setting up remarketing for abandonned cart shouldn’t the filter i exclude be /thank_you, as according to your article it is \/checkout\/processing, but processing ( will take into consideration successful transactions and declined transactions) so by using \/checkout\/processing, wont that make it so that people that successfully completed the transaction will be added to your abandoned cart remarketing list, let me know, thanks again Philip

    • There are several ways to define an abandoned cart audience. If using Google Analytics, I suggest you just do the shopping stage variable. An exclusion rule is not needed. If you do visits to the /cart page or other checkout pages, yes, exclude the thank you page.

  • Hello.
    Great material. Thank you

    Wanted to ask , i have already an existing view wit a lot of information. When i create a new “”view” in order to use it for filters and adjust it , i see that it does not get all the info that exist in the original view but starts to gather data from this time on . I tried copy the view and the same happens

    Is there a way to get all the info to the new View somehow ?

  • Great tutorial for ecommerce shops! Thanks

  • Joshua, thank you for this comprehensive guide. This has been extremely useful. I consider myself fairly familiar with the GA basics – no expert by far – and there have been several great updates I have made to our site walking through this guide. Our shop has been “soft-launched” since Fall 2016 but only in the last few months have we started ramping up efforts and wanted to kick off 2018 with a more coherent strategy. I will be sure to recommend this for others in similar situations.

  • Awesome post! Super thorough. Google Analytics is never incredibly easy to understand with all the sea of data available in the platform. I’ll be trying these out and referring others here as well!

  • It is a wonderfull tutorial I love it

  • On Topic #12, step #3… I believe you mean to say “Go to Google Analytics. On the left-side, go to “Acquisition” > “Search Console”? 🙂

  • Thanks so much Joshua… truly an amazing piece of work and great help and so kind of you. 🙂

  • Hi Joshua.
    Very accurate step-by-step tuto. Thanks a lot!
    I have just one question: what’s the current status (on 2018-02-25) about gtag.js?

    • Shopify have told me there are no plans to move over to a gtag.js setup. If you are on Plus, as you have access to the checkout.liquid, you can create your own migration. It is disappointing given this is the new standard by Google. What this means for store owners is unclear. A core proposition of feature development in Shopify is simplification – that is one big reason people love them – and from that comes security and reliability, but they also have to weigh up other features.

      gtag.js doesn’t load a new library unlike previous upgrades. The current analytics.js is still loaded with gtag.js. What it aims to achieve is unification and through that – simplification.

      Browse the Shopify forums and you get an abundance of people I’ve tried to help who struggle to implement remarketing, AdWords conversion tracking, event tracking, and other features. gtag.js makes this easier.

      There is no rush, however, for any website owner to use gtag.js. Given that, perhaps Shopify is just waiting.

  • Hi there! Just want to check if this is updated? When I tried going through the checkout process on my shopify store the url seems very different. For example:

    reached checkout: /1759848/checkouts/d17b360eae4bdb8c9e87a43becf7eb59?_ga=2.227091933.1901508662.1526890444-1762077384.1470130078&discount=

    shipping method: /1759848/checkouts/d17b360eae4bdb8c9e87a43becf7eb59?step=shipping_method

    and sometimes when customer exits the funnel at a step, and then resumes the checkout, the step will not even be indicated in the url. It will just be a generic checkout url even though they are at a specific steps.

    • Having the same issue here. Any advice would be much appreciated – thanks!

      • What are your domains? I can check it out and review the funnel.

        • Hi Joshua,
          Great guide, I was just wondering if you had a chance to see whether the funnel needed updating. I checked a website I manage and saw the following URLs, will these work?



          • As mentioned in the guide guys:

            Shopify uses virtual page views for the checkout pages, which means the URL you see in the address is different to what is pushed inside the analytics.

  • This is amazing, blew my mind into whats possible. Thank you!

  • Avatar for Philip Diehl
    Philip Diehl
    July 7, 2018 4:49 am

    For cross domain tracking I have a and a Do I include the sub domains in the linker code?
    gtag(‘config’, ‘UA-XXXXXXXXX-1’, {
    ‘linker’: {
    ‘domains’: [‘’, ‘’]

    Or do i include the https://? Or do I just leave it at


  • i have a simple but frustrating question. I enabled my client’s shopify site for ecommerce in GA and Shopify, checking the Enhanced box in Shopify, enabling both in Analytics. I’d attach photos for proof but cannot leave attachments in this post. anyway, GA is passing all day, but no data is passing through ecommerce. sales are occurring in Shopify, but none of this shows up in ecommerce GA, including add to cart, product views, etc. should i create this through tag mgr? funnell? any thoughts out there? thank you.

  • Thanks for the excellent article!

    I have bumped into an issue though: while setting up Adwords Remarketing with my account linked to Analytics, I get the error message “Your Google Analytics tag is missing “product ID””.

    All my transactions, goals, funnels are being correctly tracked on GA. What gives??? I’ve been all over trying to find a solution, hopefully you can help. Thanks in advance.

  • Hi, I implemented all this back in February and was working perfectly until early may. The checkout complete funnel tracking no longer works – it appears Shopify made some changes to the checkout URLs in May and Google Analytics is no longer recognising the steps you have listed above in the Funnels & Goals section. I feel this may need updating.

  • Hi, great article. A few questions on your content grouping above (currently implementing based on the Debut theme).

    1) What about search pages? Should there be a separate regex expression (if so, not sure how to write it? regex isn’t my best) encompassing the main search page and search results?

    2) Similarly, what about the /cart page?

    3) What about /checkouts/ (or is it /checkout because Shopify uses virtual pages) pages?

    4) Last, what about URLs that have multiple terms in them? This seems to happen when clicking to a product page from a collection page. For example the URL has both /collections/ and /products/ in it. Does it start from the right most part of the URL and work left or maybe it looks at the canonical URL?

    Thanks in advance.

    • Use the content drilldown report, Will. I recommend that more than manual content grouping given Shopify has a repetitious URL structure.

      • Thanks Joshua, I set the drill down report ups as well. I will use that.

        I’m not entirely sure what the advantages and disadvantages of each method are. Thought maybe I’d set up both just in case? But will go with the drilldown report.

  • Hi Josh, I set this up exactly as you described (regarding Goals) and yet it is simply not working. I cannot figure out why.

  • Hi Joshua, an additional question relating to regex.

    I used your template to add the goal funnel to my analytics account – easy to do. Thanks for that.

    Question 1) I’d like to add collections and the home page to my goal funnel. I’ve looked around for example regex to do this but so far I haven’t found anything that looks like it works. At least it doesn’t work when I use an online regex evaluation tool to try the regex I’ve found for these steps on the standard Shopify URL structure.

    These are the ones I’ve tried in my goal funnel:

    Home Page: ^\/(\?.*)?$
    Collections Page: ^\/collections\/([a-z0-9]|-)*\/?(\?.*)?$ and ^/collections/([a-zA-Z0-9]|-|?page=[0-9])*$

    Do you know what regex statements I would be needed to add collections and the home page steps to a goal funnel? I’m in the process of setting up a new store so unfortunately I don’t have the luxury of having prior transactions to verify the goal with.

    Question 2) I’ve seen others suggest a different regex statement for use in Goal Funnels and content grouping. However, I can’t tell why one would choose one version of each regex statement or the other. Do they do the exact same thing? Does one offer and advantage over the other? Etc.

    Here are the alternative regex statements I’ve found. The products one in particular has 3 alternatives (one from your goal funnel template, one from your content grouping suggestion, and an alternative which I’ve seen suggested for use in both goal funnels and content grouping). The collections one I’ve seen 3 alternatives too – it is a bit confusing:

    Collections regex: ^/collections/(.*?)$ or ^\/collections\/([a-z0-9]|-)*\/?(\?.*)?$ or ^/collections/([a-zA-Z0-9]|-|?page=[0-9])*$

    Product pages regex: .*\/products\/.* or ^.*/products/(.*?)$ or ^.*\/products\/([a-z0-9-]*)\??.*?$

    Pages regex: ^/pages/(.*?)$ or ^\/pages\/([a-z0-9-]*)\/?\??.*?$

    Blog Posts regex: ^/blogs/(.*?)$ or ^\/blogs\/([a-z0-9-]*)\/?\??.*?$

    Thanks in advance.

  • Updated the guide to recommend adding in the referral exclusion list.

    • Hello,
      I added to our referral exclusion list and to the additional scripts in Shopify but it still shows up as a referrer. Any guess as to why?

  • Avatar for Lisa Groeneveld
    Lisa Groeneveld
    October 5, 2018 3:36 am

    Hi Joshua,
    Great guide. There appears to be conflicting information on the code for setting up User Id tracking.

    My code currently looks like this in Additional Google Analytics JavaScript:
    ga(‘require’, ‘linkid’);
    if(__st[“cid”]) ga(‘set’, ‘&uid’, __st[“cid”]);

    Based on a previous comment, I think my code is wrong? Any ideas? Thanks so much for your help!

  • Hi Joshua
    Thanks for such a useful article.
    It seems that the native shopify GA Enahnced Ecommerce doesn’t push refund information to GA. Are you aware of this? If so, can you recommend a workaround?
    Many thanks

  • Hi Joshua,

    I’m not too sure my but my goal tracking seems to be off compared to shopify.

    I’m using /checkout/thank_you as the destination.
    Shipping – > /checkout/shipping
    Cart – > /cart
    Contact Info- > /checkout/contact_information
    Check Out Shipping – > /checkout/shipping
    Check Out Payment – > /checkout/payment
    Check Out Processing – > /checkout/processing
    Check Out Thank You – > /checkout/thank_you

    The customer download page is similar to this, I’m just not sure which tags/ending to use. When I type in the following and try to verify the conversion rate it’s really low.

    Check Out Order Status – > /STOREID/orders/{{ orderpath }}

  • Easy to follow and implement. Made one mistake but not too worried about that as I didnt have enough data to worry about. (I added a property on Search Console that said wasnt linked, but it was) Oh well.

    One area. I wasnt clear on is;

    6. Mimic the settings from your “Filtered View” covered throughout this guide into your “User ID View”. The primary things you want is the enhanced ecommerce tracking, view filters, and view settings.

    Not clear on what you mean here.

  • Added the section and code for the Checkout Behavior report that all stores can now use.

  • Hi Joshua,
    Thank you so much for taking the time to write this excellent article. I’ve just finished setting up GA for our new website using your wonderful guide and I am excited to see/ analyze the results.
    All the best for you and your team!

  • Hi Josh,
    I was wondering if you could tell me what script to enter for Google Analytics Dynamic Attributes for Shopify. I’ve been searching for the correct line of script to enter for the Product ID, Page Type and Total Value but CANNOT seem to find anywhere with recent info on this. All the info I can find is from 2 or more years back which I don’t trust as being accurate.

    Thanks so much!

  • Thank you, thank you, thank you… the whole article was very helpful.. just one comment..
    On the Ecommerce section, Related products have been deprecated.+
    thanks again

  • Avatar for Andrew Austin
    Andrew Austin
    February 8, 2019 5:08 am

    Thank you so much for this guide! Saved me a tremendous amount of time 😀

  • Thanks so much. This is a great guide!

  • This was so helpful, thanks!

    One thing that didn’t work for me was clicking on the links for your couple custom reports. It opened GA, had a “loading” popup, then did nothing. Any idea why? Thanks!

  • Avatar for César Paternina
    César Paternina
    February 21, 2019 4:27 am

    Fantastic article! Everything works for me!

  • Anyway to add a funnel to at the checkout for carthook?
    I have carthook as replacement for shopify checkout.
    I cant seem to know where to start implementing

    • Go through the checkout yourself. Copy the URLs of each page. They may change per user but it will likely follow some type of consistent pattern. Then you can create a goal that fits the criteria.

  • thank you, great tutorial. thanks for the work invested.

  • This a terrific article, Josh. It’s amazing you’ve kept it updated for so long.

    One question I can’t seem to find the answer for: I’m trying to set up Google Optimize for our site. Pasting the code into the additional Javascript section in Shopify Admin doesn’t work (I get an error message saying “Analytics extra is disabled for the moment”). I’ve had to resort to removing GA tracking from Shopify Admin and pasting the tracking code manually in theme.liquid. But that disables Enhanced Ecommerce, right?

    How do I fix this?

    • @PA – You need to ask Shopify support to enable editing. They say it was a security setting they set on all stores earlier this year (2019). Annoying, but I get it. Keep the checkout locked tight. They’re pretty fast about fixing it.

  • Hi Josh, I have added goals to google anyalics using your Shopify goal checkout template 7 days ago. There has been purchases since, but there is still 0 conversions showing for the Thank you page.
    I had added goals for other pages previously and they are all working except for the /checkout/thank_you goal. Do you know how I can solve the issue?

    • Peter, so you’ve clicked on the funnel template provided and using that as is? Common errors include changing the destination match method, requiring all steps to be completed when all steps are not actually part of every purchase, and less so, custom filters modifying the URLs. Good diagnosis is viewing the Behavior > All Pages report then looking at the URLs you think are not matching to see what version of them is coming through. You should see /checkout/thank_you exactly like that in the “Page” column.

      • Thanks for the quick reply! Yes, I tried using the funnel template as it is, without changing anything. Yesterday, I set a new goal, without the funnels, just using /checkout/thank_you. But In contrast to the template, I changed the goal details to general expression instead of equals to. Now the conversions are working 🙂 But of course, it would be nicer to get your funnel to work. I was wondering if that would also work with your template.

  • Hey Josh, great article!

    Is the Shopify.Checkout.step in the Checkout Behavior Report is for Shopify plus users only?

    Many thanks

  • Avatar for Aprameya Rajput
    Aprameya Rajput
    June 14, 2019 7:55 pm

    Thanks for the article Joshua.
    Q. For tracking campaigns, the URL’s become extremely long after using the campaign builder tool. Do you recommend use of URL shorteners for the same? If yes, then which ones? Is there any impact of using these tools and does the shortened URL expire after few days or it can be used for eternity?

    • Depends where you use the URLs Aprameya. If they have an anchor text different to the URL, it doesn’t matter how long the URL is. If it’s a link on a Facebook Ad, they have query tags you can use instead. You can use a shortened URL if you want. It’s expiry would entirely depend on the service.

  • Thanks for the article Joshua
    Q. The additional Javascript Code:
    is unique for each Shopify shop and theme correct?

  • Avatar for Patricia Stevenson
    Patricia Stevenson
    July 15, 2019 3:23 pm

    Hi Joshua – this is brilliant, thank you. However, despite having same tracking ID on both sites ( and, and the linking set up as above, I’m still not getting the ?_ga= appearing on the destination site (Shopify). Both sites have different client IDs/GIDs listed when I switch back and forth. Is it likely that Shopify is stripping the parameters? I’ve been on this for days…

    • I’ve never looked into it because every store should have a primary domain for SEO. Meaning, the domain, which shouldn’t get any traffic in the first place, will 301 to the primary domain.

      • Does this mean you should not have separate GA for and I have a client who has GA for both, but I can’t figure out how to make them talk to each other. I know I’m missing something…

  • Hi Joshua!

    Followed everything to the dot and everything works perfectly! There’s one bit that I don’t understand tho… On the Checkout Behavior Analysis part, why is that that I have more “SESSIONS WITH TRANSACTIONS” than other parts of the checkout process prior to that like “CONTACT INFORMATION” and “PAYMENT METHOD”?

    Hope I’m making sense and looking forward to hearing your response.

    Many thanks, Joshua!

  • Hi Joshua,
    How do I add multiple snippets in “Additional Google Analytics JavaScript”?
    In your guide, there are 2 sets of codes that I need to add. Can I just add them one after another? Sorry, I am not a coder.

    • What do you mean by “multiple snippets”, Charlie? If you mean multiple lines of code as per the guide, yes, you paste them one after the other. Put each on a new line.

  • Hi Joshua

    How do we address some of these problems if we are using non-plus?

    – Product names being sent to Shopify has variant information added to the end like ‘DR MARTENS | 1460Z DMC 8-EYE BOOT | CHERRY SMOOTH – 3 / red’ . This makes reporting difficult.
    – Product impression and clicks are missing.
    – How can we send checkOut option. I will like to send type of shipping used or payment method selected .
    – how can we make use of Custom Dimension and metrics.

    • Hi Nitesh,

      1 and 2 are not changeable if you use Shopify’s Google Analytics native integration as given in this guide. I don’t know what you mean by “checkout” option in 3, but it sounds like part 8 of the guide with the checkout behavior report. Your last question about custom dimension and metrics are beyond the scope of this guide, but you can see an example of this with dynamic remarketing in my Google Shopping book.

  • Hi Joshua,

    Thanks for the detail of this post. It’s very helpful. One problem we have not been able to solve is the ability to capture custom UTM parameters as “Custom Dimensions” in our GA, due largely to our inability to edit the GA tag when using Shopify’s native GA integration. Do you happen to have a post that details how we can accomplish this while maintaining the standard ShopifyGA integration?

    Thank you again for all the great content in this blog!



  • Good stuff! Clear, concise and targeted.

  • THE GREATEST ARTICLE ON google – shopify, thanks for the step-by-step guide!

  • I’m so glad I found this guide, and that the guide led me to this website. I’m reading and consuming like crazy.

    One question… Do you have instructions somewhere on how we can group URLs with different parameters into one? Ie. /products/product-a?campaignid=13691497 should be grouped under /products/product-a

    All sources I found seem to contradict one another.


    • Section 6 partly discusses dealing with query parameters. If you’re getting a campaignid parameter as per your example in your analytics that you do not want, at the view level, enter campaignid in the “Exclude URL Query Parameters” field. If there’s more than one you want to exclude, separate each value by a comma.

  • Im so thankful to this guide 🙂 Kudos!

  • Awesome post!!! Thank you

  • Hi Josh, Great article! I have enhanced ecommerce set up but the cart value is not populating. Anything that I need to do on my end for this? Event Value and Avg. Value shows as $0 for all Events.

  • Hi Josh

    Thank you for the comprehensive article, it is super helpful.

    Ref the code you provided for the Checkout Behaviour report. My additional Google Analytics JavaScript box currently includes the HTML tracking code for GA as this is the only way I could get it to work.


    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘UA-EXAMPLE-1’);

    Would I add the additional code for Checkout Behaviour and also the Enhanced Link Attribution underneath this?
    Thank you in advance

    • There’s no reason for that additional code to be there, Lucy. Everything will and should work without it. I suggest you follow the guide. The Checkout Behavior, Enhanced Link Attribution, and User ID tracking code would replace it. (Or be at the bottom if for whatever unusual reason, you kept that redundant code in there.)

  • I have a dumb question… Is there a way to edit an imported content group? because I imported the Digital Darts: Content Drilldown content group template, but the thing is that it doesn’t include the blog pages traffic, and we’re about to launch a new blog, so we would love to have that metric measured too.

    • The report does include blog traffic. The only case I can think of when it may not is your blog is on a different platform and your analytics setup is either not on the platform or your views are filtered to exclude the blog. You can click on “Edit” from the top of any custom report to customize it.

  • Hello. Thanks for the provided guide.
    “Edit each Buy Button code to replace with” – I am missing something, because this obviously does not work, changing this:

    Also, how to ensure that attribution works for Ads and Facebook conversion given:
    – Shopify is only in checkout and there are buy-buttons used on the product details page?
    – cross-domain setup

    I get almost all converted traffic is Direct.

  • So we’ve excluded but it still shows up in our traffic. Any ideas on how to fix this?

  • Super amazing guide and works perfectly for us.

    Is there similar for WooCommerce as looking at our woo GA now compared to this new setup it seems like dark ages stuff!

    Thanks you so much for this.

Comments are closed.

Get Your Free 4 Rules of Store Growth:

Follow For Weekly Shopify Marketing Tips

Get A Free Facebook Ads Audit(For serious Shopify businesses only.)

Discover the exact ways you're wasting ad spend, an overview of the strategies done or not done that are killing it for our clients, and further ways to grow in profit. Our goal is that you'll love what you see and want to work with us.