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 forever 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.

Grab a fine cup of tea with a scone, 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.”

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

The Google Analytics for Shopify Checklist by Digital Darts

1. Follow Google Analytics Best Practices: Simple things everyone should do.

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 their 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 your whole store together into one analysis.

5. Track Cross-Domains: Gather accurate data from other domains or sub-domains like a WordPress blog without messing the data.

6. Track Internal Search: Learn what people want from your store. Searchers are buyers.

7. Track Demographics: Know your most profitable audiences.

8. Funnels and Goals: See where users drop-off along the checkout process.

9. Use Enhanced Link Attribution: Better understand user behaviour on pages to help increase conversions.

10. Fix Spam Hits: Make your analytics more accurate. Protect yourself from bots and competitors.

11. Track Logged In Users: See how high-value users logged in to your store interact with it across multiple browsers and devices over their lifetime.

12. Identify Organic Search Keywords: Discover organic keyword rankings in Google including clicks, ranking improvements from SEO, and growth opportunities.

13. Track Every Campaign: Know the exact visitors and sales from specific tweets, emails, and any promotional material.

14. 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.

15. Report and Analyze: Don’t stop after collection, it’s time to report and analyze the splendid data you collected.

16. Review the Results and How to Get Help: What to look for and how to solve problems. I can do it all for you.

1. Follow Google Analytics 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.

If you have two stores that are different businesses with the URLs and, use different properties, which means a different analytics ID. If the websites are similar businesses that serve different regions and you give users the option to swap between the stores, use the same property ID then setup cross-domain tracking as indicated in the guide to retain the original traffic information. You can then filter the views to get store-specific informaiton.

Classic Analytics is ancient and hardly supported. Universal gives you more flexibility like custom dimensions that is great for highly-targeted remarketing.

You want at minimum two views. One view should have no filters, no ecommerce tracking… nothing! It is your benchmark to see what goes on. Name it something like, “Your Store Name – Original View” or “Your Store Name – Filtered View”. If you currently have one view, create a new one then make that your untouched view. It is critical to do for this guide. Your other views should have filters, ecommerce tracking, goals, and all the fancy jazz that changes data you collect. This means if you setup User ID tracking, you have to configure the view with the steps in this guide to receive clean data.

It distorts data. Google search “IP address” to discover yours. Inside your Google Analytics, go to “Admin”, select the view you can edit, 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. Make sure this is not for the original view as you want that untouched.

Some Shopify themes are pre-installed with Google Analytics. 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 ga.js, dc.js, or analytics.js are present. I recommend you use the analytics code in Shopify as taught in this guide rather than hard-coded in the theme because you are future-proofed with analytics updates done by Shopify and your theme developer.

An annotation is a comment you can insert with any date just below most line graphs. I recommend you annotate changes to analytics so when analyzing and reporting in the future you quickly review possible explanations for 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 this to the next level by annotating major marketing events like a mention by an Instagram influencer or warning by Google Webmaster Tools.

Analytics annotations

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. Follow Google’s steps to create an account until you come across your 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 *****! 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:

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-177091-1', 'auto');
ga('send', 'pageview');


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

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

Google Analytics view section

4. Enable ecommerce and enable related products then click “Next step”:

Enable ecommerce and related products

Related products lets Analytics automatically generate a list of related products per product. You can use this data to improve product bundles, merchandizing, and email campaigns.

5. Enable “Enhanced Ecommerce Reporting” then click “Done”:

Enable enhanced ecommerce for Shopify

6. An optional configuration not done here (because most Shopify stores can avoid it) is funnels and goals. A funnel or goal alters the “Checkout Behavior” report in “Shopping Analysis” of Google Analytics. The report provides specifics about the checkout process. Non-Plus Shopify members cannot edit the Shopify payment page on so it is only useful for Plus members.

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.

To track additional checkout behaviors like the selection of a product upsell at checkout, you need to create custom javascript or datalayer events inside your theme. You can literally track anything. Simo Ahava has a good guide to do so amongst many excellent technical guides on Google Analytics.

7. 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:

Click to reveal the enhanced ecommerce code

<script type="text/javascript" class="analytics">// <![CDATA[

window.ShopifyAnalytics = window.ShopifyAnalytics || {};
window.ShopifyAnalytics.meta = window.ShopifyAnalytics.meta || {};
window.ShopifyAnalytics.meta.currency = 'AUD';


(function () {
var customDocumentWrite = function(content) {
var jquery = null;

if (window.jQuery) {
jquery = window.jQuery;
} else if (window.Checkout && window.Checkout.$) {
jquery = window.Checkout.$;

if (jquery) {

var analytics = document.createElement('script');
var loaded = false;
var onload = function() {
if (loaded) return;
loaded = true;
window.ShopifyAnalytics.lib =;
window.ShopifyAnalytics.lib.initialize({"Google Analytics":{"trackingId":"UA-177091-1","domain":"auto","siteSpeedSampleRate":"10","enhancedEcommerce":true,"doubleClick":true,"includeSearch":true}});

window.ShopifyAnalytics.lib.ready(function() {

ga('require', 'linker');
function addListener(element, type, callback) {
if (element.addEventListener) {
element.addEventListener(type, callback);
else if (element.attachEvent) {
element.attachEvent('on' + type, callback);
function decorate(event) {
event = event || window.event;
var target = || event.srcElement;
if (target && (target.getAttribute('action') || target.getAttribute('href'))) {
ga(function (tracker) {
var linkerParam = tracker.get('linkerParam');
document.cookie = '_shopify_ga=' + linkerParam + '; ' + 'path=/';
addListener(window, 'load', function(){
for (var i=0; i < document.forms.length; i++) {
           var action = document.forms[i].getAttribute('action');
           if(action && action.indexOf('/cart') >= 0) {
addListener(document.forms[i], 'submit', decorate);
for (var i=0; i < document.links.length; i++) {
           var href = document.links[i].getAttribute('href');
           if(href && href.indexOf('/checkout') >= 0) {
addListener(document.links[i], 'click', decorate);

var originalDocumentWrite = document.write;
document.write = customDocumentWrite;
try {  } catch(e) {};
document.write = originalDocumentWrite;
analytics.onload = onload;
analytics.onreadystatechange = function() {
if (!/complete|loaded/.test(analytics.readyState)) return;
analytics.async = true;
analytics.src = "//";

var eventsListenerScript = document.createElement('script');
eventsListenerScript.async = true;
eventsListenerScript.src = "//";


// ]]></script><script type="text/javascript" src="//"></script>

Don’t see this code? Contact Shopify support and they can advise you what’s going on.

8. 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:

  • (if you’re not a Shopify Plus member)
  • (or the URL of any payment gateway. If you’re unsure of what this, you can wait a few days to see your referrals report for the source of transactions.)
  • (visits from the admin dashboard)

If you use other payment methods, 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 The easiest way to confirm what to add is looking at the referrals report for revenue data from payment gateways.

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 accurately optimize 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 I have below for content groups is not ideal, an excellent alternative for most stores is the Digital Darts: Content Drilldown report.

Content drilldown

That is a powerful report to frequent and analyze.

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 all 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 customized 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. Requires advanced coding knowledge.
  • Group using extraction: Shopify has a consistent URL structure so 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 get highly customized 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

Go 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 analyze their performance with primary dimensions and segmentation in standard or custom reports.

5. Track Cross-Domains

If you have a WordPress blog or any page on a sub-domain being tracked, the URL of pages in analytics appear as if they were URLs on your store. It makes reporting inaccurate and analysis difficult.

Secondly, if someone clicks a Facebook link to a post on your WordPress blog (or any page that isn’t on Shopify) then goes to your store, the original user data is lost. Google Analytics will think the person on your store came from the blog rather than Facebook.

Go to your “All Pages” report then from the secondary dimension field, select “Hostname”. You will see websites where your analytics snippet is used. If you have a blog on, you will see that hostname. If you followed the section on enhanced ecommerce and have a non-Plus plan with Shopify, you will see mentions of

Sub-domain hostname data in Shopify

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. Yes, you need to use the same analytics ID on the domains.

2. If you own another domain like a WordPress blog at, you need a special tracking code otherwise the original traffic source is lost between domains. Copy the below code to all pages you want to track. Paste it after the opening <body> tag. Replace XXXXXXXX-X with your analytics ID and with the domain of your store:

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-XXXXXXXX-X', 'auto', {'allowLinker':true });
  ga('require', 'linker');
  ga('linker:autoLink', [/^.*yourstore\.com$/]);
  ga('send', 'pageview');

The linker plugin appends all links (on pages that have the tracking code installed) 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', [/^.*yourblog\.com$/]);

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

7. (Optional) Use (.*) instead of ( in the hostname field to reveal the full URL for all domains. I normally ignore filters for because its pages are obvious. I suggest you read about the Custom Field 1 filter to see how Shopify handles hostname data on checkout pages.

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. Ignore the “Site search categories” option. In the rare case 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.

8. Save and you’re setup. Like all G 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 in G analytics that lets you segment your data to extract more value. In my fashion garment example, I used this segment combined with a referral traffic report.

7. Track Demographics

The demographics report is viewable in the “Audience” section. The demographics configuration lets you learn how people of different ages and genders interact with your store. Though males age 18-24 may visit your store most often, 25-34 year old females could be your most profitable demographic.

Shopify automatically loads the displayfeatures analytics plugin with your Universal Analytics setup (so you do not need to include “ga(‘require’, ‘displayfeatures’);”), but you need to configure your analytics account to track demographic information.

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

2. Turn on “Enable Demographics and Interest Reports” then save.

Enable demographics and interest reports

3. The last step in analytics is in “Reporting” > “Audience” > “Demographics” > “Overview”. Click “Enable”.

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

8. Funnels and Goals

Identify where people exit and enter the checkout process. This is useful for all stores, but it’s most powerful for Shopify Plus subscribers because they can act more on the data by customizing 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

9. 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');

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

Shopify analytics configuration

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

The report is available in “Behavior” > “In-Page Analytics”. Browse your website like a normal user to see the fancy data when you’re logged into your Google Analytics account. Only you can see the click behavior.

10. 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? Your business would be hurt. Unwanted hit information distorts your aggregated data like page views a session, conversion rate, and page value.

View the referral traffic coming to your store at “Acquisition” > “Referrals”. You may see mentions of Semalt, 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 like Semalt 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 not too many 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. a) Are you Shopify Plus member? 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.

b) Are you a Shopify non-Plus member? You require an extra step. If your users proceed to payment through the domain, 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.

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 backslash.

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

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) If you’re really keen or still see 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.

One final note: you will exclude your YouTube channel if it’s linked with your analytics (you can also add to your filters) or other VPNs from legitimate users (like with such filters.

11. Track Logged In Users

When you track logged in users, you begin to calculate customer lifetime value, analyze where high value customers come from, and re-market to your biggest customers from the moment of implementation. Most stores have historical customer data that presents re-marketing 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 optimize 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 privacy 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 because users are unidentified on pages. 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);

Unfortunately anonymousId(); varies between your own store and

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"]);

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:

userId in Shopify

8. View the various cross device reports under the “Audience” section of analytics:

Cross device analytics

12. 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 Webmaster Tools. It is my favorite and recommended tool to monitor Google ranking data.

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

1. Go to Google Webmaster Tools. Login or signup for an account.

2. Verify your store with Google Webmaster Tools by following Shopify’s documentation. I prefer to verify a store with a file upload to minimize code in the head of pages.

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

4. Follow the directions to enable Webmaster Tools in your analytics account.

Google may have up to 90 days of data on your store even if you setup Webmaster Tools 5 minutes ago. 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:

Search engine optimization queries

13. Track Every Campaign

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. You must use this feature for all marketing campaigns if your serious about growing your store.

Every store should do what they can to minimize 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 with the tool is consistence of the UTM parameters for your campaigns. 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”.

14. 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 optimize 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. 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.

Google Custom Alerts is one strategy to save you time and manage the marketing performance of your store. 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 the data in analytics, an alert can be setup to track the data. Google has pre-built alerts under “Intelligence Events” > “Overview” that are okay. You need to login each time to view these automatic alerts:

Automatic alerts

To setup an alert:

1. Go to “Admin” then “Custom Alerts”. Be sure you’re under your filtered view.

2. 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:

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 issues with paid advertising not driving the traffic they should be. 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:

Period: Day
This applies to: Visitor 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

15. Report and Analyze

What you learned in the The Finest Google Analytics Setup in Shopify for Splendid Data is 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

Out of the box reports in analytics are not overly insightful with the exception of identifying traffic sources that lead to visitors and revenue. Get comfortable working with primary dimensions, segments, and custom reports to extract the data you need for growth.

16. 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.

Two of the most important reports in your filtered view that will show if you’ve done the tutorial right is the source of sales. Seeing these reports reflect the data of your sales does not mean everything is setup right (there are so many ways I’ve seen a Shopify analytics setup go wrong), but they are basic checks that provide coverage of what was taught. 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 no revenue data.

The shopping behavior report should also show full data:

Need help cart abandonment

If you are worried about what you did or you want other custom work done, let me save you. I 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. I will have everything in this tutorial working for you within one week for an investment of AU$597. For another AU$200, 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, AdWords, product performance, collections performance, and more, so you can grow the store. Contact me to have an invoice sent to you.

Fixes and additional customizations are also possible. I have figured out how to extract historical customer spend and order counts out of Shopify into Google Analytics so that you can re-market to your biggest customers and do other analysis. Message me with what you’re after.

About Joshua Uebergang

Joshua Uebergang is founder and Head of Strategy at Digital Darts. He helps Shopify stores get more of the right visitors and convert them into sales. At 6'9", yes, he plays basketball. Get extra tips and tricks from him to build your ecommerce store by entering your email below.

Liked this article? Get more free Shopify guides:


108 Comments. Leave new

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.


Good to hear you got your analytics working Karrie.


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?


User accounts are the whole premise of cross-device tracking. It’s how the user can be identified first on your system then analytics.


[…] source of most of your sales is with e-commerce tracking in Google Analytics. Even with the perfect analytics setup for your store, you can miss where someone first heard about […]


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?


Hi Adrian,

You need custom work to setup the necessary steps so the data can be collected to make use of this report. That is probably why you cannot see it.


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!


Thanks Raghav. Agree, store owners do not know how to get value out of analytics aside from the obvious visitors, sales, and conversion rate. Thinking I will write something. In the meantime, you can get my conversion optimization book that has a few special analytics reports:

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.


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)


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.

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.

Russell Smith
April 13, 2016 1:50 pm

Thanks Joshua, sorry for the confusion!

Appreciate your help 🙂

– Russ

Hey Joshua,

The goals and funnels part is the only thing which isn’t clear. The rest of the guide is crystal clear and easy to implement.

If you dont mind can you please elaborate a bit on how non plus owners can setup goals & funnels?


Hi Dave, I’ll be adding a section on funnels soon that all stores can use.

The current funnels part refers to the Checkout Behavior report and it is too advanced and pointless to go into here, when Simo covers it (my suggested resource in the link).

EDIT: This has been updated as section 8 of the guide.


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.



Yes, definitely Ivan. Nothing is different with events in Shopify. Last year I setup events for a client to track social shares on all major platforms. Did this through Google Tag Manager. Add to Cart clicks are already setup in enhanced ecommerce. For 404 errors, I find it simpler to use a custom report that looks for the title of your 404 page because the page view is tracked in analytics. You can get mine at:


Is that possible to track embedded videos and embedded audio player as well?


If you’re using YouTube videos for a channel you host, I recommend just setting up then referring to YouTube analytics. It gives you more insight than a simple click event.


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?


Nothing in the pipeline yet Dan. Need a rest after writing the monster SEO guide. You can get a sample of help in making use of analytical data from the positioning section of my book:



One slight tweak the code I think now should be:

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


Javascript in “Additional content and scripts” at the checkout like the userId should have script tags wrapped around them, Sam. You probably mistook it for the “Additional Google Analytics Javascript” which should not have script tags.


I just realized Sam, you’re right with the userID change. I’ve updated the guide. Keep the script tags though.


Hi Josh, yes it’s working for me, I used that code above.


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?


Hi Agustin. Yes, you can see my analytics service at the bottom of the article.


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


I keep getting an error in the JavaScript console after adding the userId line of code to theme.liquid. I also tried Sam’s recommendation of changing &uid to userId.

Uncaught ReferenceError: ga is not defined

Any suggestions?


See the updated line of code Brian. Use the userID but keep the script tags.

Edit: I’m getting the error now too. After investigation, the Shopify Analytics code is not loading in time once the UserID is pushed. Shopify may have changed something with their use of which is used to load the tracking code. I have updated the user ID code to fix this error by having jQuery load the javascript after document load. This solution is still imperfect as the jQuery selector doesn’t seem to be working on the thank you page.


A great article but I’m having one problem. Ecommerce tracking isn’t working. In GoogleAnalytics it is showing as set up and Shopify has everything set, but nothhing is being recorded in GA. The ret of GA seems to be working.

Any ideas on where to look?


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


I’m have the same problem as as Dan Knowlson. I’v gone back to check my settings twice. Is this article up-to-date?


Yes, it’s extremely up-to-date. Check your filters. Everyone screws that up. I can’t do much more than write a large guide with full step-by-step details and offer my services to help people.


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.


Good spot Siavash. Updated it and also any directions for the new admin layout as it seems to have rolled out to most of my clients now.


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 (


Yes, use the same ID for the same domain and that includes sub-domains.


Thank you, sir!


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 Dave,

Got a little question for you. We see a large perfect of our conversions being attribute to people mysteriously landing on the virtual checkout pages.

I believe it might have to do something as we use two URLs for our store: and Due to having multiple URL’s we can’t use the redirect to primary.

I’ve modified our filter to be .*englishstore\.com.*|.*frenchstore\.com.*|store\.myshopify\.com.*|\/checkout.* as a consequence.

Is there something I shoudl be doing with the linker attribute as well on ?


Feel free to change the name Dave to Joshua 🙂


Unlikely to be the filter Philip. Segment the data based on common attributes you see and you can try mimic the behavior by debugging in Chrome with the suggested browser add-on.


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.



Firstly Julia, the User ID tracking you have is wrong and not suggested in the guide. But yes, the lines of code can and should co-exist.


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


Both are correct Jon. Basically the same thing. The slashes and dollar signs is regex.


Aha – thanks. Obvious now you point it out of course 😉


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.


Are you talking about the custom alerts? You probably selected a limited time frame.


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!


Section 10.4.b.v… sounds like a legal document 🙂 Corrected. Screenshot did show the right thing to do.


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?


Same here. Have you gotten the solution already:?

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.


You ignore those other tracking codes completely.


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?


Leave a Reply

Your email address will not be published. Required fields are marked *