The Finest Google Analytics Setup in Shopify for Splendid Data

212 Comments

Get everything to configure the ultimate Google Analytics 4 setup for Shopify in this splendid tutorial. The guide was first published in 2015 for Universal Analytics. Since then I’ve kept it up-to-date when I discover a feature that helps merchants better use the analytics platform.

Nearly all guides published about Google Analytics for Shopify in some way have copied code or concepts from this tutorial. Owners of development agencies tell me they link to this guide as their standard operation procedure to set up Google Analytics for 8-figure brands. Digital Marketing Evangelist for Google and author of Web Analytics 2.0 Avinash Kaushik called the first edition 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 make intelligent use of analytics to grow your store.

Reports and analysis are difficult or inaccurate without clean data. A worker in an offline retail store has the benefit of talking with customers. You may only talk with a rare customer who purchases 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 my team can do it for you. 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.”

There’s first a short section on how to migrate To GA4 in Shopify and a bullet-point primer to help you get up to scratch. From there, you’ll get a step-by-step tutorial to configure analytics in Shopify. Let’s crack into it.

Google Analytics in Shopify

How to Migrate To GA4 In Shopify

The History Of Google Analytics And Why You Must Migrate To GA4

On July 1, 2023, standard Universal Analytics properties will stop processing new hits. 360 Universal Analytics properties will stop in October. Google’s announcement is part of their push to move analytics into a web era that no longer looks at single sessions, depends on cookies, and is driven by desktop devices.

GA4 is the first Google Analytics tool that uses event-based data instead of cookies. Chrome in 2024 will be cookie free, forcing the analytics team to get GA4 in the hands of companies otherwise there will be many useless features like in-market and affinity audiences. (Will the cookie monster from Sesame street move to keto?)

The history of Google Analytics helps you see how we got here today as Shopify merchants need to migrate to GA4. In October 2012, Google released Universal Analytics. Now called GA3, the solution aimed to give insight into a multiple device world as users began to swap between desktop, laptops, tablets, and mobile phones. GA3 is backwards compatible with classic analytics, first released in 2005 after Google acquired Urchin.

Since Universal Analytics is backwards compatible with Classic Analytics, this means the primary analytics tool of today uses 2005 technology. The tool can slow page load time-to-completion. Even worse, if cookies are not set, which browser security settings and extensions can easily do, Google Analytics cannot collect data.

In 2017, Safari released Intelligent Tracking Prevention to limit third-party domains from using cookie data over long-periods of time. In response, Google released gtag.js in 2017 as part of GA3.

Are you seeing the trend here? New technologies are released as people demand more privacy. Some requirements are from law. Other changes are a positional strategy in the market like Apple who continues to tighten privacy on their devices and technology.

The inevitable termination of GA3 is enough to reason to follow this tutorial to migrate away from GA3. You are forced to migrate to GA4.

Beyond the requirement to move away, there are upsides to doing it that can help you make better decisions. GA4 looks at attribution beyond last-click, letting you change the attribution model through the account rather than providing a few measly multi-touch reports. IP addresses are no longer stored. There’s privacy controls at the country level. A person can be even better identified across devices rather than being seen in the data as multiple people.

How To Back Up Universal Analytics Data

The data in GA3 will eventually become inaccessible. To backup this data, you can export any report in CSV and PDF formats. You can also use the API to export data. Google says, “We intend to offer more guidance on data export as we approach the date when Universal Analytics is no longer available.”

I recommend you export your own CSV files in July 2023 when data collection ends. It is quick to do. That way, you can have all the historical data. Keeping it in CSV format lets you manipulate the data should you want to later on.

The Cliff Notes Of What You Need To Know About GA4

New tools take time to get your head around. I want to speed up the learning for you. This is a summary of points that matter most to help you transition your Shopify from GA3 to GA4:

  • Run GA3 with GA4.
  • Your data in GA4 is not backfilled. You collect data in GA4 only when it is set up.
  • The new interface feels intimidating for those familiar with Google Analytics. I hate the lack of tabular data. Data is grouped into insights. Give it time and you will become more comfortable.
  • GA3 is based on sessions and pageviews. GA4 is based on events and parameters. A pageview happens through an event.
  • Modelling patches information impossible to track with the user identity if the user ID, Google Signals, and device ID is unavailable. This can happen if the user is: not logged into the store, not logged into Google, and blocking cookies.
  • New engagement metrics are engaged sessions, engagement rate, engaged sessions per users, and average engagement time.
  • You can automatically measure page views, scrolls, outbound clicks, site search, video engagement, and file downloads through the “Enhanced Measurement feature”. All these were previously doable in Universal Analytics, but now it’s automated.
  • If your Google Ads is linked to analytics, you need to review bids on imported goals and transactions for GA3. Audiences created in GA3 will be phased out as well so seek to create the equivalent in GA4. GA3’s imported site metrics used in columns also need to be updated.
  • GA4 ecommerce data is somewhat reverse-compatible with Universal Analytics. You don’t need a new setup to get these reports working. You can use your current GA3 tags to feed GA4 reports. However, Shopify uses an old version of GA3 through analytics.js so you have to push ecommerce data yourself into GA4. This guide shows you how.
  • If you’re on Shopify Plus, you have access to the checkout.liquid file giving you extra flexibility to track event data at checkout.
  • Google in Skillshop has a GA4 certification. Do it if you have time, but you’ll get far more out of completing this guide.

How to Set Up and Configure GA4 with Shopify for the Best Data

Here is our client checklist for the perfect Google Analytics 4 (GA4) setup with Shopify:

The Google Analytics 4 for Shopify Checklist by Digital Darts

1. Google Analytics 4 Setup Best Practices:

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

2. Install Google Analytics 4 on Shopify:

Collect all the standard analytics information correctly from your Shopify.

3. Track Ecommerce Data:

Collect purchase data, items ordered, shipping, taxes, and discounts. The powerhouse of the checklist.

4. Track Conversions:

Identify the events like purchases that matter the most to you.

5. Set Up Funnel Exploration:

See the steps people take to complete a purchase. You get to visualize where they succeed or fail at each step.

6. Enable Enhanced Measurement:

Measure page views, scrolls to the bottom of a page, outbound clicks, internal site search, video engagement, and file downloads with no code.

7. Set Data Retention Period:

Prevent the deletion of data from reports.

8. Link Google Search Console:

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

9. Configure Google Ads:

Get new engagement metrics in Google Ads, improve bidding, and create detailed audiences for observation and targeting optimization.

10. Manage Unwanted Referrals:

Retain the right traffic source with payment gateways and apps. Otherwise all sales come from PayPal.

11. Set Up Cross-Domain Measurement:

Gather accurate data from other domains like an international store or a WordPress blog without messing data.

12. Fix Spam Hits:

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

13. Strip Unwanted Query Parameters:

Consolidate reports about pages that are the same.

14. Enable Google Signals:

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

15. Set Up Reporting Identity:

See how customers or people logged-in to the store interact with it across multiple browsers and devices over their lifetime.

16. Track Internal Search:

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

17. Create Content Grouping:

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.

18. Import Cost Data:

Merge data from a CRM, non-Google ads platform, or other silo to give you new insights. Most commonly used for cost data in social ads.

19. Configure Attribution Model:

Select the right attribution model to assign credit of the touchpoints on a conversion path.

20. Get Custom Insights:

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.

21. Ongoing Best Practices:

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

22. Reports:

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

23. Troubleshooting:

How to spot problems using the best tools.

24. Need help?

We can do it all for you.

Get The Free Shopify Google Analytics 4 Audit Checklist

Before you continue the Google Analytics tutorial for Shopify, I created the ultimate 32-point spreadsheet to have by your side that works beautifully with the tutorial. The sheet walks you through the article as you track edits in one neat page so you get your setup right.

1. Google Analytics 4 Setup Best Practices

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

Run GA3 with GA4

Google even recommends you run this parallel tracking. Ecommerce data in GA4 is not as robust as GA3. Out-of-the-box revenue reports for ecommerce are “Monetization overview”, “Ecommerce purchases”, and “In-app purchases”.

Assess data to collect

Are there additional websites, conversions, or Shopify apps to track? Define what you want to collect because you can track a thousand variables and never be done.

Set the right account structure

There are three levels in an account: account, property, and data stream. Subproperties also exist in 360 accounts to further compartmentalize data. Google advises the use of one account for one company, and one property for the same stores. At the data stream level, use one data stream for all web activity then one for the iOS app of the store and one for the Android app of the store.

Track all pages

Check Google Analytics is on all web properties for the business like a support desk or WordPress blog. If you’re on Shopify Plus, track page views at the checkout. Track any URLs generated by a software or app. The best practice of assessing data to collect gets you to discover what pages to track.

Align property settings with Shopify settings

The industry category, time zone, and currencies in “Property Settings” should align with Shopify. Check your currency and time zone settings in Shopify by going to “Settings” > “General”. I’ve worked with several store owners who worried that sales were inaccurate in Google Analytics compared to Shopify. Part of the problem was that sales were pushed differently between days due to the disparity in these settings.

2. Install Google Analytics 4 on Shopify

There are several ways now to set up Google Analytics 4 on Shopify. I created a Google Tag Manager custom solution before 7-months before Shopify released a native option. I will show you how to use Shopify’s option and then share with you GTM. I suggest you use Shopify’s solution to capture more event data until you want a custom solution.

Regardless of what option you choose, you need to create your Google Analytics 4 account.

Create Your Google Analytics 4 Account

  1. Go to your Google Analytics account. Select Admin from the bottom-left.
  2. Click “GA4 Setup Assistant” under the Property column.
  3. Click “Get Started” under “I want to create a new Google Analytics 4 property”:
Google Analytics 4 property setup assistant
  1. Click “Create property”:
Create a new Google Analytics 4 property

Do not check “Enable data collection using your existing global site tag(s).” You will see the message “Based on your current tag setup, you’ll need to install new tags on your site to use GA4.” This is because of what I explained earlier with Shopify not using gtag.js in their native Google Analytics. Google’s own documentation is miss-leading saying, “If you use a website builder/CMS that already supports the gtag.js tag (e.g., WordPress, Shopify, Wix, etc.), you may have the option to Enable data collection using your existing tags.” Ignore that.

Your GA4 property is set up. Your GA3 property is untouched. You now need to collect GA4 data in Shopify.

Option 1 to Install GA4 on Shopify: Google Channel App

  1. Install the Google channel app for the store.
  2. Connect your Google account to the channel.
Connect Google account to Shopify
  1. Follow Google’s prompts to allow and authorize.
  2. If you’ve already installed the channel or you only want to set up analytics without any Google Ads or Merchant Center configurations, click the shortcut “Get started”.
Setting up only Google Analytics in the channel
  1. Click the Google Analytics 4 account you want connected then click “Connect”.
Connect Google account to Shopify
  1. You should see a confirmation message that you’ve successfully set up Google Analytics 4. Now you can get insights into your online store’s performance with Google Analytics. It’s never been easier to get Google Analytics data pouring in.

The rest of the guide will show you how to configure Google Analytics while also helping you understand the platform.

Option 2 to Install GA4 on Shopify: Google Tag Manager

Google Analytics 4 can be set up on Shopify without the Google channel. Go this route when you want the freedom to customize everything without the constraints of Shopify’s native solution. To know the how the constraints don’t align to what you want, you need to test it out.

I use Google Tag Manager instead of theme edits to minimize issues with developers and theme updates. Furthermore, you can use the GTM tags that I’m about to handover to you to kickstart your tags.

Install Google Tag Manager

  1. Create your Google Tag Manager account. Select your container to be “Web”:
Create Google Tag Manager container for Shopify
  1. Install the two snippets of code given to you to set up Google Tag Manager.
  2. For the first snippet:
    1. In your Shopify admin, click “Online Store” then click “Themes”. For your live theme, click “Actions” then “Edit Code”.
    2. Select your theme.liquid file.
    3. Find the opening <head> tag then paste the first snippet as per Google’s instructions after the tag:
Insert Google Tag Manager near head tag in theme.liquid of Shopify

You cannot install Google Tag Manager within the custom JavaScript section of Google Analytics. Shopify has made Google Tag Manager exclusive to Plus stores. However, this statement is miss-leading. Any store can use the tag solution, but non-Plus stores cannot have it at checkout. If you add GTM to the additional Google Analytics scripts then view the developer console of your browser, you will see several Content Security Policy directive reports like “[Report Only] Refused to frame ‘https://checkout.shopify.com/’ because it violates the following Content Security Policy directive: “child-src c.paypal.com cdn.shopify.com cdn.shopifycdn.net”. Note that ‘frame-src’ was not explicitly set, so ‘child-src’ is used as a fallback.” Many years ago you could make it work, which is why there are wrong, out-of-date guides elsewhere teaching you otherwise.

  1. For the second snippet:
    1. Find the <body> opening tag then paste the shorter, second snippet as per Google’s instructions after the tag:
Install Google Tag Manager near body tag in theme.liquid of Shopify

Set Up Google Tag Manager for GA4 in Shopify

  1. Go to your GA4 property, select Admin from the bottom-left then click “Data Streams” under the Property column:
Data streams in GA4
  1. Click the existing data stream created for you then copy your measurement ID. Your ID begins with “G-”.

To save time, you can skip the following steps in setting up GA4 in Shopify. Jump to the next section of tracking ecommerce data. In it, I provide you a Google Tag Manager container to track all pages in Shopify using GA4.

  1. In Google Tag Manager, click “New” to create a new tag.
  2. Name the tag “GA4”.
  3. For “Tag Configuration”, select “Google Analytics: GA4 Configuration”.
  4. Enter your measurement ID.
  5. For “Triggering”, select “All Pages”. The tag will look like this:
GA4 tag in Google Tag Manager for Shopify
  1. Click “Save”.
  2. Verify Google Tag Manager and your GA4 tag is installed correctly in Shopify by using Preview mode in Google Tag Manager. This will then open up the Tag Assistant page. Visit the homepage of the store for confirmation in Tag Assistant that the container is loaded. If you’re on Shopify Plus, also go to your checkout to confirm the container is loaded there.
GA4 tag firing in GTM for Shopify
  1. In Google Tag Manager, click “Submit” to publish your tag. You now have GA4 setup in Shopify. The bare minimum for GA4 in Shopify is done.

You will still see the “GA4 Setup Assistant” under the property column of your GA3 analytics. That is fine to ignore as clicking it will take you to your new property.

3. Track Ecommerce Data

If you’re using Shopify’s native solution, you can skip this step. The section teaches you how to do it in Google Tag Manager.

GA4 does not create a separate plugin like Universal Analytics to collect ecommerce data. You’re only required to collect the data as variables inside Shopify then push them as events into GA4.

  1. In the Shopify admin, go to “Settings” > “Checkouts and accounts”.
  2. Underneath “Order status page” in the “Additional scripts” section. Replace GTM-XXXXXXX with your Google Tag Manager ID.
<script>
  // Google Tag Manager dataLayer and events for order status page by DigitalDarts.com.au v1.1
  var gtmId = "GTM-XXXXXXX";

  (function() {
    window.dataLayer = window.dataLayer || [];
    dataLayer.push({ ecommerce: null });

    // Prevent double-tracking if an upsell is seen or the order status page has been seen
    {% if first_time_accessed == true and post_purchase_page_accessed == false %}
    var checkout = window.Shopify.checkout;
    dataLayer.push({
      event: "dl_purchase",
      ecommerce: {
        transaction_id: "{{ order.order_number }}",
        affiliation: "{{ shop.url }}",
        coupon: getDiscountAmount(),
        currency: checkout.total_price_set.presentment_money.currency_code,
        items: items(),
        shipping: checkout.shipping_rate.price,
        tax: checkout.total_tax,
        value: checkout.total_price_set.presentment_money.amount
      }
    });

    function getDiscountAmount(line_item_count) {
      if (checkout.discount === null || typeof checkout.discount === 'undefined') return '0';
      if (checkout.discount.length === 0) return '0';
      if (line_item_count === undefined) {
        return checkout.discount.amount;
      } else {
        if (checkout.line_items[line_item_count].discount_allocations[0].amount === null || typeof checkout.line_items[line_item_count].discount_allocations[0].amount === 'undefined') return '0';
        if (checkout.line_items[line_item_count].discount_allocations[0].amount === 0) return '0';
        return checkout.line_items[line_item_count].discount_allocations[0].amount;
      };
    };

    function items(){
      var jsonarray = [];
      for (var line_item_count = 0; line_item_count < checkout.line_items.length; line_item_count++){
        var jsonobj = {
          item_id: checkout.line_items[line_item_count].product_id,
          item_name: checkout.line_items[line_item_count].title,
          currency: checkout.total_price_set.presentment_money.currency_code,
          discount: getDiscountAmount(line_item_count),
          price: checkout.line_items[line_item_count].line_price,
          quantity: checkout.line_items[line_item_count].quantity
        };
        jsonarray.push(jsonobj)
      };
      return jsonarray;
    };
    {% endif %}

    // Google Tag Manager
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer',gtmId);
  })();
</script>
  1. If you have an upsells using Shopify’s post-purchase page, add the following code in the “Additional scripts” of the “Post-purchase page”. Replace GTM-XXXXXXX with your Google Tag Manager ID and https://shopifydemo.com with the domain of your store.
<script>
  // Google Tag Manager dataLayer and events for post-purchase page by DigitalDarts.com.au v1.1
  var storeUrl = "https://shopifydemo.com";
  var gtmId = "GTM-W2MF8S7";

  (function() {
    window.dataLayer = window.dataLayer || [];

    // Make sure the initial purchase event isn't tracked twice
    if (!Shopify.wasPostPurchasePageSeen) {
      var order = window.Shopify.order;

      // Track event dl_purchase in GTM with ecommerce parameters
      window.dataLayer.push({
        event: "dl_purchase",
        event_id: order.id,
        ecommerce: {
          transaction_id: Number(order.number).toString(),
          affiliation: storeUrl,
          currency: order.currency,
          items: order.lineItems.map(function(item) {
            return {
              id: Number(item.id).toString(),
              name: item.title,
              category: item.product.type,
              price: item.price,
              quantity: item.quantity,
              variant: Number(item.variant.sku).toString(),
            };
          }),
          shipping: (parseFloat(order.totalPrice) - parseFloat(order.subtotalPrice)).toFixed(2).toString(),
          tax: '0',
          value: order.totalPrice
        }
      });
    }

    // Set up additional purchase tracking
    Shopify.on('CheckoutAmended', function(newOrder, initialOrder) {
      // Identify which items were recently added, if any
      var oldItems = initialOrder.lineItems.map(function (line) { return line.id; });

      var addedItems = newOrder.lineItems.filter(
        function (line) { return oldItems.indexOf(line.id) < 0; }
      );

      // No new items were added, so we skip conversion tracking
      if (addedItems.length === 0) {
        return;
      }

      // Track upsell event dl_upsell_purchase in GTM with ecommerce parameters
      window.dataLayer.push({
        event: "dl_upsell_purchase",
        event_id: order.id,
        ecommerce: {
          transaction_id: Number(order.number).toString() + "-US",
          affiliation: storeUrl,
          currency: order.currency,
          items: addedItems.map(function(item) {
            return {
              id: Number(item.id).toString(),
              name: item.title,
              category: item.product.type,
              price: item.price,
              quantity: item.quantity,
              variant: Number(item.variant.sku).toString(),
            };
          }),
          shipping: (parseFloat(newOrder.subtotalPrice) - parseFloat(initialOrder.subtotalPrice)).toFixed(2).toString(),
          tax: '0',
          value: (parseFloat(newOrder.totalPrice) - parseFloat(initialOrder.totalPrice)).toFixed(2)
        }
      });
    });
    
    // Google Tag Manager
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer',gtmId);
  })();
</script>
  1. Download our GA4 for Shopify Google Tag Manager container.
  2. In Google Tag Manager, click “Admin” > “Import Container”.
  3. Choose the downloaded container file. For the “choose workspace” option, select “Existing”. If you have nothing set up in Google Tag Manager, click “Overwrite” otherwise click “Merge”. Click “Confirm”.
  4. Click the “GA4” tag and replace {{Insert Your G- ID}} with your measurement ID.
Google Measurement ID in GTM

See the section “Set Up GA4 in Shopify” to see how to retrieve your measurement ID.

  1. Click “Submit” to publish your tag. You’re now tracking ecommerce purchase data through GA4 in Shopify.

The code set up will track purchases in GA4 when an upsell is never seen, rejected, ignored, or accepted. These are all the conditions to account for on the post-purchase page. Upsell purchases have the same order ID number but are suffixed with “-US” to distinguish an upsell. You can create your own “Shopping Performance” report like the following screenshot to verify orders:

Shopping Performance report in GA4

If you go into reports and don’t see any monetization reports, it’s likely because GA4 hasn’t received the event data yet. GA4 automatically recognizes what reports to display to you. The ecommerce data you collect is available in Reports > Monetization > Ecommerce Purchases.

For a full list of ecommerce variables to implement, refer to measure ecommerce in GA4’s documentation. If you want to capture this data, I recommend Elevar. The owner Brad has done a great job at building out a tagging solution that doesn’t require expertise in code.

4. Track Conversions

Conversions in GA4 are simple goals of GA3. A conversion is easier to set up compared to GA3 since it’s based on a single event name and all event data is shared with you, allowing you to turn on or off what is a conversion.

Non-Shopify businesses that have gtag.js set up with goals, are able to migrate their goals to GA4 with the click of a button. The primary conversion to review in Shopify is the purchase event:

  1. From the bottom-left side of GA4, click “Admin”.
  2. Click “Conversions”.
  3. Turn on “purchase” if Google hasn’t automatically turned on the purchase event.
  4. If “purchase” is not turned on by default, you may need to go to the “Property” column then click “Events”. Turn on the purchase event. Next, hover over the event then click the three vertical dots to check it is not marked as “no personalized ads” (NPA).
Purchase event pushing through in GA4
  1. Create other conversions that make sense for your store. Example conversions are email opt-ins, PDF downloads, ambassador enquiries, and wholesale enquiries. Send these as events in GTM then in the configure section of GA4, mark them as a conversion. File downloads like PDFs can be automatically tracked using enhanced measurement, which I’ll show you how to set up soon.

5. Set Up Funnel Exploration

Funnel exploration lets you see the steps people take to complete a purchase, a download, or any other task important to your business. You get to visualize where they succeed or fail at each step.

  1. Go to your GA4 account. Click “Explore” > “Funnel exploration”.
Funnel Exploration
  1. Configure the steps from the left to suit your needs and setup. If you’re on Shopify Plus, you can add checkout pages. I’ve found purchase data in the report to be non-existent when working with the report in the last 3 days.
  2. You can begin to ask yourself in the funnel exploration report, how do first time visitors become buyers? How do one-time customers become repeat customers? For more helpful analysis, use segments to break out your data with variables like someone’s country or the traffic source of their first visit.

6. Enable Enhanced Measurement

Enhanced measurement in Google Analytics 4 lets you automatically measure interactions with no edits to code. Events include page views, scrolls to the bottom of a page, outbound clicks, internal site search, video engagement, and file downloads.

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Data Streams” > “Web”
  3. Enable enhanced measurement:
Enhanced measurement
  1. If there’s events you don’t want pushed through, you can click the cog icon to disable any event, but page views, created by enhanced measurement.
  2. See the events pushed through from “Configure” > “Events”:
video_start, video_progress, video_complete events in GA4

The following gives you more details about each event created from enhanced measurement and when it triggers:

  1. Page views. Event: page_view. Each time the page loads or the browser history state is changed by the active site
  2. Scrolls. Event: scroll. The first time a person reaches the bottom of each page. When a 90% vertical depth becomes visible. If you want other scroll thresholds or horizontal scroll tracking, you can do that through events in Google Tag Manager.
  3. Outbound clicks. Event: click. Each time a person clicks a link that takes them away from the current domain.
  4. Site search. Event: view_search_results. Each time a person searches on the website. q, s, search, query, and keyword are automatically tracked. Shopify’s default search query parameter is q. Internal site search is discussed later in the guide.
  5. Video engagement. Events: video_start, video_progress, and video_complete. Google says the events will trigger for embedded videos that have JS API support enabled. Embedded YouTube videos are tracked. video_start fires when the video starts playing. video_progress fires when the video progresses past 10%, 25%, 50%, and 75% duration time. video_complete fires when the video ends.
  6. File downloads. Event: file_download. When a person clicks a file that ends with pdf, xlsx, docx, txt, rtf, csv, exe, key, pptx, pps, ppt, 7z, pkg, rar, gz, zip, avi, mov, mp4, mpe, mpeg, wmv, mid, midi, mp3, wav, or wma.

The information fills your engagement reports. For more help, like knowing what parameters fire with each event, see Google’s documentation on enhanced measurement.

7. Set Data Retention Period

The data retention settings control when user data, event data, and advertising identifiers are deleted from Google Analytics servers. Data like conversions is removed from exploration reports after your set time.

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Data Settings” > “Data Retention”.
  3. The default setting is 2 months. Once 2 months elapses, you’re no longer able to search exploration reports. The data is available only in standard aggregated reports. Follow your privacy requirements first. If you can, I recommend setting the data retention period to the maximum of 14 months.
  4. Enable “Reset user data on new activity”. This resets the retention period of the user identifier with each new event. The expiration date of their data is the current time plus retention period.
Data retention period in GA4

8. Link Google Search Console

What search terms do you rank for in Google organic search? How many clicks did you get last month from a search query? 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.

By linking Google Search Console to your GA4 property, you gather new data into the property and new dimensions for reporting. What is least known is it helps attribution reports.

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Search Console links” then “Link” to be taken to the “Link setup” page:
Google Search Console link
  1. Select your Search Console account to link. You need to be a verified site administrator of Search Console property and be an Administrator of the Google Analytics property. If your store is unavailable to link, here’s how to verify it:
    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.
  2. Select the web stream for the store.
  3. Review and click “Submit”.

The integration enables two reports:

  1. Queries. Gives you search query data associated with Search Console.
  2. Google Organic Search Traffic. Gives you landing page data associated with Search Console.

The reports are hidden by default. Click “Reports” on the left then at the bottom of left navigation, click “Library”:

Hidden library in GA4

Find the “Search Console” collection then publish it:

Publish Search Console reports in GA4

Google may have up to 90 days of data on your store if you just set up 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 the “Queries” report of a Shopify SEO client:

Queries report in Search Console of GA4

How can you use this integration to grow your Shopify store? At Digital Darts we primarily use it for a gap analysis of Google Ads and SEO to help us understand what keywords are missing from either channel that is used on the other. There may be search queries with a low click, but high impression, volume in organic search that can be targeted in Google Ads.

9. Configure Google Ads

You gather extra columns to make more informed decisions in Google Ads when it is linked with Google Analytics. You also get to import audiences and track conversions set up in analytics.

You can link Google Analytics to Google Ads in either platform. I’ll show you how to do it through Google Ads.

  1. In Google Ads, from the top go to “Tools and Settings” then “Linked accounts”.
  2. Locate “Google Analytics (GA4) & Firebase”. Click “Details”.
  3. Select the property you want to link to the Google Ads account. Click “Link”.
  4. Enable “Import Google Analytics audiences after linking”. This enables “Personalized Advertising” within the Google Ads and Google Analytics link.
Import Google Analytics audiences after linking
  1. Activate the “Apps and web metrics” option. You may have to wait five minutes up to a few hours, for the option to become available.
Apps and web metrics in Google Ads

When it is available, you’ll need to refresh the page in your browser for the “Activate” button. You could stare at it, hitting refresh every minute or jump to another step.

  1. Modify your columns to use three new metrics: % engaged sessions, events/sessions, and avg. session duration (seconds).

GA4 columns are distinguished from UA (GA3):

Google Analytics metrics in Google Ads

They are good proxy metrics to estimate whether underperforming keywords, search queries, and ads may drive sales data compared to keywords, search queries and ads that are driving sales on target.

  1. If you have GA4 conversions you want in Google Ads, from the top of Google Ads, click “Tools and Settings” then “Conversions”. Click “+ New conversion action”. The “Import” will let you gather a conversion from your GA4 property.

It’s time to create some audiences in Google Analytics that can be used for Google Ads.

  1. In Google Analytics, from the left click “Configure” then “Audiences”. You may see two audiences created called “All Users” and “Purchasers”.
  2. Click “New Audience”. You have a few options to create new audiences. I suggest you select the predictive audiences that are made eligible once your analytics tracks at least 1000 purchases. There’s users who are likely to make a purchase in the next 7 days, purchasing users who are likely to not visit your property in the next 7 days, and more:
Predictive audiences not eligible

Here’s a sample of other custom audiences I suggest to get your mind running with what you can create:

Non-purchasers. Include Users when: no conditions. Temporarily exclude Users with the event “purchase”. Membership duration is set to the maximum limit.

Non-purchasers audience in GA4

page_view (7 days). Include Users when the event is page_view. Membership duration is 7 days.

page_view (30 days). Include Users when the event is page_view. Membership duration is 30 days.

page_view. Include Users when the event is page_view. Membership duration is set to the maximum limit.

Google has other suggested audiences for ecommerce that are dependent on event data in your setup.

  1. Add the audiences to your campaigns. If your analytics audiences aren’t available in Google Ads, you may have to wait a whole day from their creation for them to sync. While GA3 is still the primary analytics platform, there’s no reason not to add a few GA4 audiences like “Non-purchases” and “page_view” in observation mode across search and shopping campaigns to collect data for future decisions.

Dynamic remarketing is the only outstanding variable for Google Ads in GA4. Google says, “Dynamic remarketing for website visitors is not yet available in Google Analytics 4 properties.”

10. Manage Unwanted Referrals

Referrals is a traffic source from third-party domains not categorized into other groupings of email, social, search, or whenever custom UTMs are used. Google Analytics identifies the domain of a referral then displays this as a referral source.

Unwanted referrals is a feature of Google Analytics that lets you identify traffic you don’t want as referrals. When you add a domain like a third-party payment tool, to the unwanted referrals, you override the attribution of previous sources. Analytics appends ignore_referrer=true to every event sent from the website hiding the referrer as a traffic source.

You do not need to add any subdomains when a domain matches the referring page. Google also says unwanted referrals are unnecessary to add, “when a user navigates across domains that you have configured in your domains list and the current page contains the linker parameter _gl.”

The most common use cases for unwanted referrals in Shopify are payment gateways and apps. Here’s how to add them and a pre-made list of URLs you can pre-emptively add.

  1. In Google Analytics, go to “Reports” > “Acquisition” > “Traffic acquisition”. Search “referral” then add a secondary dimension of “Session source / medium” from “Traffic source”. It’s rare to have to select more than a 30-day period since traffic that should be in unwanted referrals typically comes in daily. Review the domains like payment gateways and apps that you don’t want there:
How to see source of referrals in GA4
  1. Click “Admin”. Select the property you want.
  2. Click “Data Streams” > “Web”. Click your GA4 tag > “Configure tag settings” > “Configure your domains” > “List unwanted referrals”.
  3. Create new unwanted referral exclusions for any domains you found in the report. Use the “contains” match type then enter the top-level domain, such as example.com, without the https:// part of the URL. All entries follow OR logic.
Shopify unwanted referrals list

You can also add my pre-made list of unwanted referrals for Shopify. Bookmark this guide since the list and everything else in the guide is kept up-to-date:

  • paypal.com – The domain of any payment gateways you use. If you use Afterpay, enter portal.afterpay.com. If you use Zip Money, enter account.zipmoney.com.au and my.zipmoney.com.au. If you use Zip Pay, enter account.zippay.com.au. If you use Klarna, enter klarnapayments.com. If you use iyzico, enter shopify.iyzipay.com. If your store accepts Amazon payments, you’ll need to add amazon.com. I’ve also seen hooks.stripe.com that needs to be added to the referral exclusion list. Go through the checkout process for each gateway then enter the domain of the gateway into the referral exclusion list. The easiest way to confirm what to add is looking at high-converting referrals.
  • checkout.shopify.com – This used to be the checkout URL of most stores, but I still notice it in other sources like draft orders.
  • pay.shopify.com – The domain used by customers during the accelerated checkout process of Shopify Pay.
  • shop.app – Shopify’s Shop app and the Shop payment option at checkout. Traffic from this has a utm_source value of shop.app. No utm_medium is set so it is a referral.
  • yourstore.myshopify.com – This is the domain of your Shopify admin to exclude referrals from the admin dashboard.

11. Set Up Cross-Domain Measurement

Cross-domain measurement in GA4 correctly attributes a user as they navigate between domains. This gives you a more accurate picture of the user journey.

A common Shopify store that needs cross-domain tracking uses third-party tools like WordPress that enable you to add Google Analytics. Another common need for cross-domain measurement are Shopify Plus stores who use country-specific top-level domains, such as .com.au, .ca, and .de for their multiple stores to communicate to customers they serve the region. I’m yet to see a country swapping app correctly handle cross-domain measurement.

Let’s say you have a WordPress blog hosted on another domain. If someone clicks a Facebook link to a blog post on your WordPress then buys on 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. First-party cookies are set on each domain making the person a new user on each domain.

On the other hand, if you have the same tracking ID and add your WordPress blog as an unwanted referral, the traffic source will be labelled as (direct)/(none). With cross-domain measurement setup, the traffic source will be from Facebook, cookie information is passed between domains, and there’s no outbound link tracked from enhanced measurement.

Cross-domain tracking is simple in GA4 with no hardcoding required. In GA3, you had to customize the tracking code with the linker plugin and modify any JavaScript to pass the _ga parameter. In GA4, we can do it all through the admin. Hallelujah!

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Data Streams” > “Web”. Click your GA4 tag > “Configure tag settings” > “Configure your domains”.
  3. Add the domains that you want cross-domain measurement. Use the “contains” match type then enter the top-level domain, such as example1.com, without the https:// part of the URL. All entries follow OR logic. If we want cross-domain between two domains on the same data stream, the configuration looks like this:
Examples of unwanted referrals in GA4
  1. Repeat the steps for all data streams that track domains you want set up for cross-domain measurement.
  2. Test. Navigate to one of your domains then click how a user would navigate to another domain. Look in your browser to confirm the _gl parameter exists in the URL like https://www.example.com/?_gl=1*abcdefg9*.

If it exists, it means your cross-domain tracking is working. All data from the previous domain like attribution and cookies will pass to the new domain. Repeat the test for every way a user can swap between the domains to confirm the _gl parameter exists.

For the more technically minded, when using the Chrome debugger extension, you want to see the “sid” parameter maintain the same value between domains:

page_view event in GA debugger with sid variable

If the _gl parameter does not exist, there’s either a URL redirect, which can be spotted with network requests of the previous page in Chrome. A second reason the parameter cannot exist is there’s a conflict with other scripts. Script issues are common in Shopify since many domain swapping apps between stores use JavaScript to navigate. If you have a script conflict, you’ll need to add a manual implementation of cross-domain measurement.

If you have a subdomain or multiple domains in one property (as you should), the data in Google Analytics is lumped together. It is difficult to distinguish between the domains. These can be separated by customizing reports with the hostname included in the Pages and screens report:

Hostname in GA4 report

12. Fix Spam Hits

Google automatically excludes known bots in GA4. Currently there is no way to disable automatic exclusion of bots or to see the excluded traffic.

13. Strip Unwanted Query Parameters

Query parameters are parts of a URL that follows a question mark. A search page in Shopify like /search?q=orange+dress will be reported for every unique search, which doesn’t make sense to keep separate for analytical decisions. Similarly, there are many other query parameters a store can use, the main one being “variant” for product pages, which makes sense to group into the parent product.

In Shopify, parameters rarely affect page content. Removing these parameters improves the data quality by grouping the pages into a single bucket as they come into Google Analytics. A native feature to strip unwanted query parameters is not yet available in GA4. With that said, GA4 has a “page path” dimension you can see in the “Pages and screens” that strips all parameters so it’s not a big deal. If you want to strip unwanted query parameters, you can modify our Shopify Google Tag Manager container using Julius Fedorovicius’ tutorial.

14. Enable Google Signals

Google signals gathers cross-device data, demographic data, and additional information about users for advertising as well as enabling remarketing in Google Ads. All features are achieved by associating visitor information with users signed into their Google account who have consented to the association for the purpose of ads personalization.

The feature requires no customization of your Shopify store or additional code. The actions required are enabling the feature and adhering to policies and laws.

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Data Settings” > “Data Collection”.
  3. Acknowledge you understand the laws and policies. You must understand your country’s data collection policies and privacy regulations before turning on the feature. By enabling Google signals, you must adhere to the Google Advertising Features Policy.
Enable Google Signals in GA4
  1. Click “Get started” then follow the prompts to activate the feature.

15. Set Up Reporting Identity

GA4 has a reporting feature that determines how it identifies users. The reporting identity lets you identify someone as they switch between browsers and devices.

When you track logged-in users, you begin to see customer lifetime value, analyze where your whale customers come from, and remarket to your biggest customers. For the same reason, if someone abandons checkout on their mobile phone and completes their order on desktop, the mobile session should be linked to the sale for its contribution.

There are four data points Google looks at in order of importance that shape someone’s identity:

  1. User ID. An ID you chose to identify someone. The User ID was first introduced in GA3 when a user logged into your Shopify store, you could send their authenticated details to verify who they were in Google Analytics. We will set this up.
  2. Google Signals. When someone is logged into their Google account at the time they access your store.
  3. Device ID. The device ID on websites comes from the client ID. This is the “cid” variable in analytics. It is the classic
  4. Modeling. When users decline cookies, Google makes it up… I mean models. Don’t ask questions. Let Google do its thing. You have the option to turn off modeling in the property settings of “Reporting Identity”.

Since Google looks at the User ID first then Google Signals then device ID, if someone is not logged into your store, is not logged into Google and is blocking cookies, only then is modeling used.

Once you have set up the User ID, when someone signs into their Shopify account, their whole session including actions from earlier, are identified to the user. If they sign out, subsequent steps are not associated.

When you track logged-in users, you begin to see customer lifetime value, analyse where your whale customers come from, and remarket to your biggest customers.

The great news? If you’ve imported our GA4 for Shopify Google Tag Manager container, it’s done for you. The GA4 sets the user_id field when a user is logged in or when the person isn’t logged in but buys. Two different objects have to be used to retrieve the same customer ID in Shopify since there’s no object that meets both conditions.

The JavaScript objects ShopifyAnalytics.meta.page.customerId and Shopify.checkout.customer_id are defined by Shopify so it’s functional for all Shopify stores. The user ID field is consistent for all pages accessed by an account holder, which is another requirement of the user ID.

If you’re an advanced user and want to know how the user ID property is discovered, log into your store. Open Chrome developer tools then go to the console then type in “window”:

window in Chrome developer tools

Click the small black triangle next to ‘window”. Hunt for ShopifyAnalytics. Shopify’s customer ID is stored there:

ShopifyAnalytics.meta.page.customerId

For orders after checkout when customers are not logged in, it is stored under “Shopify” > “checkout” > “customer_id”. The IDs will match (in the case of these screenshots, they’re from two stores):

Shopify.checkout.customer_id

If you’re not logged in then buy, ShopifyAnalytics.meta.page.customerId doesn’t exist at checkout. So, the user ID is set by the following code in the GTM container:

function () {
  if (Shopify.checkout && Shopify.checkout.customer_id) {
    return Shopify.checkout.customer_id;
  } else if (ShopifyAnalytics.meta.page.customerId) {
    return ShopifyAnalytics.meta.page.customerId;
  };
}

The ID is perfect to use since it doesn’t require datalayers or liquid, plus it is not personally identifiable like an email.

One check I suggest you do for the user identity is:

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Reporting Identity” then select “Blended”:
Google Analytics reporting identity blended

Internal search tracking in Google Analytics lets you see what people search on your store so you discover what they want. The information lets you see how people who search arrive in your store, how you can better provide what people want, and the differences between those who search and those who don’t. It also gives you ideas for product opportunities.

People who search your store are more likely to buy than those who do not search. The behavior of searching shows they are at the bottom of the funnel wanting a particular product.

I’ve seen research data suggest 40-50% conversion differences between searchers and non-searchers. Having analyzed client stores, it depends on your niche. I think low SKU stores have no need for internal search as everything should be accessible. High SKU stores will see higher conversion differences between people who use internal search and those who do not. My rule of thumb is to have a search field on your store if you stock over 30 products for good usability.

I picked a fashion client at random who uses internal search. I analyzed almost $3 million dollars of transactions over two months comparing people who search and those who do not. Internal searchers convert a whooping 87% higher and buy more per order:

Ecommerce Conversion Rate of Performed Site Search

It’s time you also extract value from this data to drive sales. One example I discovered working with another 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.

You only need to set up search tracking if your store has a search field. To configure internal search tracking for your Shopify store:

  1. Enable enhanced measurement. You did this earlier in the guide. By enabling enhanced measurement, analytics will track the internal search results of most Shopify stores with the event view_search_results and parameter search_term. You are about to confirm if you need to customize the feature for your store.
  2. Go to the homepage of your store then type any term in the search box.
  3. Look at the URL to identify the search query parameter. Shopify’s default search query parameter is q. A parameter is the bit after the respective ampersand and immediately before the equals sign. A URL can have many parameters but only one for the search query. In the first example, it is “q”:
http://yourstore.com/search?x=0&y=0&type=product&q=search+term

The search query parameter is “b” in this example:

http://yourstore.com/search?&b=search+term+two&ajax=yes

If your search parameter is “q”, “s”, “search”, “query”, or “keyword”, enhanced measurement will track internal search. There’s nothing further you need to do. If your search parameter is something different, continue with the steps to track internal search.

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Data Streams” > “Web”. Click your GA4 tag > “Configure tag settings”. Click the cog icon to edit “Enhanced measurement”:
Edit enhanced measurement
  1. Click “Show advanced settings”. The “Search Term Query Parameter” field will already contain “q,s,search,query,keyword”. Add another comma then insert the search query parameter used on your site.
  2. Add any optional “Additional Query Parameters”. This is worth it if you have several search boxes for different purposes like a product search versus an article search, or your search box customizes other parameters that you may derive insights from. Sometimes internal searches in Shopify can contain a second parameter that controls 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 third step then add that in this field. If the search URL is /search?type=product&q=test, you’d add the “type” query parameter:
Search term query parameter

Google Analytics 4 does not include built-in Site Search reports. To create a basic internal search report:

  1. Click “Reports” on the left then at the bottom of left navigation then click “Library”.
  2. Click “Create new report” and select “Create detail report”. Select the “Events” template to speed up the creation of the report.
  3. Remove the current dimension then select “Search term”. Click “Apply”. You can browse other dimensions that are available for inspiration of what you can derive insights from. Ask yourself a question like, “What operating system, pages, or regions lead to more internal search?”
  4. Under the “Event count” metric column, select “view_search_results”. Save the report naming it “Internal Search”.
view_search_results event

If you’re an advanced analytics user, and want to extract more value, create an audience named “views_search_results” using the event “view_search_results” and set the membership duration to the maximum limit. You can then segment your GA4 internal search data with the audience:

view_search_results audience

17. Create Content Grouping

Let’s say you have a blog for your store. You understand the critical part to content marketing is 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 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 Grouping in Google Analytics helps you solve this issue. The feature helps you identify the influence your blog, support pages, and other types of content have on purchases. If you have collections and products split between genders, you can have a men’s bucket and a women’s bucket in the content group. If you have a “News” blog and a “Guides” blog, each can be their own bucket.

  1. Import our GA4 for Shopify Google Tag Manager container. If you’re following the GA4 Guide for Shopify top-to-bottom, you’ve done this in the “Track Ecommerce Data” section. The container has content grouping in the “GA4” tag using the “Content Grouping” variable. This variable is a regex table suitable for all Shopify stores that splits content into five buckets of “Blogs”, “Collections”, “Pages”, “Products”, and “Other” with a sixth bucket of “Checkout” for Plus stores that have GTM installed in checkout.liquid:
Content grouping for Shopify in GTM
  1. If you’re curious about customizing content grouping, the trick is to plan. Create a new Google sheet then figure out what buckets all URLs should go in. If you want to be sure you have accounted for all pages, use Screaming Frog’s Spider Tool. Refer to Google’s documentation on content grouping for further help to gather custom content grouping data.
  2. You can check your content grouping is working in Tag Assistant by clicking the GA4 tracking ID then clicking the “Config” message. Lastly, click the “Page View” event. There should be an event parameter of “ep.content_group”:
GTM content group ep.content_group debugging
  1. Register content_group as a custom dimension to expand your reporting options. In Google Analytics admin, click “Configure” then “Custom dimensions”. Create a new custom dimension with the following properties:

Dimension name: content_group
Scope: Event
Event parameter: content_group

When doing this for clients, I’ve found you need to wait a few hours for the content_group event parameter to become available.

content_group custom dimension

Once you are finished with the configuration of your content groups, you will have richer reports. You can view your content groups from the “Pages and screens” report then select “Content group” from the dimension dropdown.

Content group dimension in reporting

You can go to “Reports” > “Engagement” > “Events” then click “page_view” and “content_group” to see realtime data:

content_group realtime events

18. Import Cost Data

The data import feature of Google Analytics lets you merge data from a CRM, non-Google ads platform, or other silo to give you new insights. A lot of this data can be joined together in Google Analytics.

The most common use of a data import for marketers is importing cost data to see what campaigns and creatives drive revenue. You upload a CSV file with the column requirements then Google joins it to your analytics. In the GA3 world, you were constrained to last-click attribution on the data import, but GA4’s attribution models make data imports even more powerful for the smart marketer.

I will walk you through doing it for Facebook ads, but  it’s very similar for Bing, TikTok, LinkedIn, Twitter, Outbrain, and other ad platforms.

  1. In Facebook ads, go to Ads Reporting. I like using a custom report here for quick access to maintain the cost data.
  2. Create a new report using a pivot table.
  3. Select your desired time-frame. As an agency, we select from when we began management. If you have imported some of the data before, that is okay since you can upload to an existing data source.
  4. Remove all columns to clean your canvas. Add all the required columns and as many optional columns that Google makes available in a data import.

The following table explains the column structure and what to select for Facebook ads. Data imports have the following required and optional fields:

Google Analytics Columns Requirement Facebook Ads Reporting Columns
Campaign ID Required Campaign ID
Campaign Name Optional, but recommended Campaign name
Campaign Source Required Platform
Campaign Medium Required Placement
Date Required Day
Impressions Optional, but the data is always available so use it. Impressions
Clicks Optional, but the data is always available so use it. Link clicks
Cost Optional, but why are you even doing this if you don’t include it? Amount spent
Facebook Ads columns export for Google Analytics cost data

These reporting columns for Facebook ads are based on the following URL parameters in ads:

utm_source={{site_source_name}}&utm_medium={{placement}}&utm_campaign={{campaign.name}}&utm_content={{ad.name}}&utm_term={{adset.name}}_{{ad.id}}

If you use static utm_source and utm_medium parameters like utm_source=facebook&utm_medium=paid, you can manually add these values in your data export. For example, your campaign name column would contain “facebook” in every row and the campaign source column would contain “paid”.

  1. Save the report. I like the naming convention “[Client Name] Cost Data for GA4”.
  2. Click the export button from the top and select the .csv format.
  3. In Google Analytics, click “Admin”. Select the property you want to import the data into.
  4. Click “Data Import” then “Create data source”.
  5. Name your data source “Facebook ads” and select “Cost data”.
Create data source for costs data in Google Analytics 4
  1. Upload your CSV then click “Next”.
  2. Select the Analytics fields and imported fields to map to one another.
GA4 cost data mapping for Facebook ads in data source
  1. Click “Import”.

Even if you stuff up the data import, you can remove the file to undo any damage since Google joins cost data at reporting or query time.

19. Configure Attribution Model

Attribution assigns credit to touchpoints of the conversion path. One of the best features of GA4 is the freedom to swap the attribution model for all reports. What’s cooler is changing the attribution model is one of few things in analytics that changes both historical and future data.

To configure your attribution model in GA4:

  1. In Google Analytics, click “Admin”. Select the property you want.
  2. Click “Attribution Settings”.
  3. Select “Cross-channel data-driven model” if your store generates over 300 transactions per month otherwise opt for “Linear”. The 300 threshold is a crude estimate I’ve made based on Google Ads thresholds where data-driven modeling excels in Google Ads. For more help with attribution models, you can learn about the cross-channel data-drive model from Google plus I’ve described the other models in our Google Ads conversion tracking guide for Shopify.
  4. Review the lookback window then save. Confirm acquisition conversion events are set to 30 days and all other conversion events set to 90 days. I see no reason for a store to use shorter lookback windows.
Google Analytics recommended attribution settings

20. Get Custom Insights

Custom insights are cards to make you aware of some data you judge as important. Google’s intent is to help you understand and act on the data. Insights can save you time managing the performance of your store.

If you can see a type of data in analytics, you can get an optional email alert for it. Maybe you want to know 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 plummets from a country.

To create a custom insight:

  1. In Google Analytics, click “Reports” from the left navigation then “Reports snapshot”.
  2. Click “Create”.
Custom insights GA4

You can create a maximum of 50 custom insights per property.

21. Ongoing Best Practices

Track Campaigns with UTM Parameters

UTM parameters make clear the source of traffic. Google Analytics automatically tracks a lot of your marketing like traffic from Google organic search, Google Ads if you have auto-tagging enabled, and other websites. However, what exact Facebook posts, Pinterest links, or offline promotion lead to sales?

URLs promoted in marketing materials not set up with the correct parameters manifest in the abyss of “Direct” traffic:

Direct traffic in GA4

Not all direct traffic is bad and avoidable. A large percentage of direct traffic for your store will come from not using UTM parameters, but other sources are people typing the URL into their browser, visits from an app, or visits from a https page to a http page.

Your goal is to minimize direct traffic sources because it provides no insight into performance. Any time you can control the URL of your website in promotions, even offline, you can track the profit of each campaign with UTM parameters.

The Digital Darts’ Google Campaign URL Builder lets you add the required UTM parameters to any link to reduce direct traffic. You can even track offline print by creating a short URL like mystore.com/winter then 301 redirect the page with the parameters from the tool.

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:

https://yourstore.com/collections/my-product?utm_source=customer-promotion&utm_medium=email&utm_campaign=summer-15-04-16&utm_content=v1

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

You can view the performance of your campaigns at ”Reports” > “Acquisition” > “Traffic acquisition”.

Annotate Major Changes

An annotation is a comment you insert into Google Analytics on a date. When it comes time to analyze or report, the annotation gives you possible explanations for unusual data changes. “Why did our time on site decrease and user sessions decrease? Oh, I see in the annotation we blocked internal traffic.”

Marketers can take advantage of the feature by annotating major marketing events like the day you got a mention by an Instagram influencer. You can also record key retail dates, holiday periods, Google algorithm updates, and news events that impact your industry.

There is no native way to annotate in GA4. However, I recommend you checkout the GAannotations – Crystal Ball Chrome extension. You can annotate from within your browser, integrate annotations with Google Ads, and create customized automated annotations specific to your store.

How to annotate changes in Google Analytics 4

Exclude Active Team Members and Developers

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

Exclusions are best done with an IP address. The method works great for static IP addresses. Unfortunately, most IP addresses are dynamic, which I think 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 your property then “Data Settings” > “Data Filters”.

You’ll get to choose two filters:

  1. Developer Traffic: Filter event data from your development devices.
  2. Internal Traffic: Filter event data that you have identified as internal traffic.

Developer traffic is automatically filtered when the event parameter debug_mode=1 or debug_event=1 is sent. Even with the filter, the DebugView is still available. When the internal traffic filter is set up, all events get a traffic_type parameter. If your exclusion filter applies, the parameter has a value of “internal”. You can learn more about GA4 data filters on Google.

Modify Event Data

You can modify event data without editing existing events or any code. How cool is that? This quickly fixes event mistakes and fills your report with cleaner data to simplify reports. You will have fewer back-and-forth conversations with developers to solve unclean event data.

Review your events in “Configure” > “Events”. Check for spelling errors, unintended characters, and any unknown names. From the events page, you can modify the data by clicking “Modify event”. You can set the name of the modification, the conditions to be met, and the modification.

Modify event data

22. Reports

What you’ve learned in this Shopify Google Analytics tutorial is data collection with a sprinkling of reporting and analysis. Throughout this guide I’ve given you reports to help you begin making decisions from the data, but for more help, a good resource is Google’s documentation on their default reports.

I think the four areas to get good comfortable with for 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 ask yourself questions. From questions come a hypothesis that you can explore. Do not mindlessly click around looking at numbers.

23. Troubleshooting

There’s no one guaranteed way to troubleshoot your Google Analytics 4 setup in this guide. It’s helpful to have several tools available. Each has its own benefits, whether it be speed, simplicity, or detail.

Rather than troubleshoot with each method in isolation, use each one during a test purchase to gather the most information at once.

GA4 Reports

The method is simple: look at GA4 reports to see what data comes in. When you use a Google Analytics report for diagnostics, select a time-period the day after the last change to see the latest form of the data.

There’s two strategies to track changes that make this diagnostic helpful. First is to use annotations. The ongoing best practice of annotating changes lets you see when changes affect data. Second is the change history of the account. In Google Analytics, click “Admin”, select the property you want, then view the “Property Change History”:

Property change history of Google Analytics

Realtime Reporting

Realtime reporting is the least useful of the methods given the tool isn’t made for debugging.

  1. In Google Analytics admin, click “Data Settings” > “Data Filters”. Deactivate the internal traffic filter.
  2. Go to “Reports” > “Realtime”.
  3. Load up an incognito tab to begin a new Google Analytics session. Visit your homepage with unique UTM parameters. If your store has no realtime visitors, you can skip appending UTM parameters since this is a trick to identify you in your analytics. Use our Google Campaign URL Builder tool to append unique UTM medium and source variables to the homepage like:
https://www.example.com/?utm_source=test&utm_medium=test
  1. Under the card “Event count by Event name”, click “page_view”. Click “source” or medium”. Check your UTM parameter is there:
Test parameter in realtime Google Analytics reports

Unfortunately you cannot add a comparison from the top to segment the data since realtime data is not supported for the comparison. That would make it too easy to determine if a purchase event came through from your session.

Cannot compare data
  1. Re-activate the internal traffic filter or return it to “Testing” mode.

Debug Mode

Debug mode of GA4 is superior to realtime reporting. The mode gives you events, event parameters, and user properties in an instant without distorting data in historical reports.

When you click “Preview” in Google Tag Manager, you have the option to tick “Include debug signal in the URL”. Include the debug signal to use debug mode in GA4.

Google warns it may break some websites but I’m yet to see that happen in Shopify. If your website does break, you can follow these alternative steps to enable debugging in tag manager:

  1. In Google Tag Manager, add an event parameter of “debug_mode” with the value “true” to each event tag you want to place in debug mode.
debug_mode true in Google Tag Manager
  1. In Google Analytics, click “Configure” then “DebugView”. You’re good to make your test purchase:
Shopify test purchase in GA4 debug mode
  1. Delete the debug_mode parameter on all tags in Google Tag Manager. Do not set it to false since that doesn’t disable debug mode. Save and publish the container.

Browser Console with Google Analytics Debugger

The browser console is the best place to debug code. It is for users who understand development since you get to see all that is pushed to analytics.

  1. Install the Google Analytics Debugger Chrome extension by Google.
  2. In Google Chrome, right-click a page you want to investigate then click “Inspect” to open Chrome’s Developer Tools.
  3. Click “Console”. Interpret the debugger using skills that pay the bills. Look for any red messages or aborting messages like “User has opted out of tracking. Aborting hit.”
Google Analytics Debugger by Google

    Google Tag Assistant

    Google Tag Assistant is an online tool to help debug all of Google’s tags. It is the best method to identify issues. If you use Google Tag Manager and want to debug that, access Tag Assistant through the preview mode of GTM. GTM preview mode does not work on the post-purchase tracking page for security reasons since you’ll get the error “Uncaught DOMException: Blocked a frame with origin “null” from accessing a cross-origin frame.”

    1. In Google Tag Manager, click “Preview” from the top to open up Tag Assistant. Connect the homepage of your store to Tag Assistant. When you connect, the homepage will load in a new tab.
    Include debug signal in the URL
    1. Return to the Tag Assistant tab. From the top, select your desired Google container. If you’re debugging this guide, you want to refer to the Google Tag Manager container that begins with “GTM-” and the Google Analytics 4 tag that becomes with “G-”.
    2. Check your GA4 tag sends a “Page View” hit:
    Page view debugging in Google Tag Manager for Shopify
    1. Select the GTM tag then see the tags that fire and the ones that don’t.
    2. Make a test purchase from the homepage window in debug mode. If you have an upsell, test that offer. Review the app’s settings to see what products will trigger a post-purchase offer. Zipify has good documentation for OneClickUpsell to confirm when post-purchase offers trigger or don’t trigger.

    There’s three ways to do a test purchase:

    1. Place a test order with a bogus gateway or if you’re using Shopify Payments, put it in test mode. Your credit card processor must be disabled, which can cause a store processing payments to mess up real orders.
    2. Place a real purchase using a credit or debit card. Create a coupon to minimize the payment amount. Refund the order after.
    3. Place a test order in Shopify using an offline payment method such as a bank transfer. Do not use this method if you have an upsell since the post-purchase offer triggers only when a credit card payment method is selected.

    If you have no upsell app, there’s no conditions to account for. If you have an upsell, then you need to test in these conditions:

    1. The upsell is seen but rejected.
    2. The upsell is seen and accepted.
    3. The upsell is seen but the page is closed so that the order status page is unseen.
    4. No upsell is seen.

    In all scenarios, you want to see the “dl_purchase” event:

    dl_purchase event firing on Shopify in GTM

    After spending hours testing post-purchase tracking, it is unavoidably sketchy. The Chrome debugger extension will only show the first three conditions of the main purchase when the dl_purchase event pushes after waiting approximately 35 seconds. As long as the dl_purchase event does show in the debugger after the unusual 35 second delay, rest assure I confirm the purchase event is pushed into analytics even when the upsell page is quickly closed.

    Also confirm all variables for the event match up to the test order:

    Ecommerce variables in GTM for Shopify

    If you’re coupling the method with the GA Debugger Chrome extension, you’ll see a “purchase” event with all your juicy parameters:

    Google Analytics debugger ecommerce parameters

    If you run upsells, look for the purchase event with its variables in the chrome extension. Debugging the post purchase is hard, but I’ve got a bunch of tips. Use a bogus gateway with the card number “1” since a credit card payment is one of the requirements for the upsell to trigger. Tick “Save this information for next time” at checkout to save yourself headaches of continually re-entering account information. You’ll want to depend on GA4’s debug preview mode to see data with the GA Debugger Chrome Extension. Even though GTM preview mode cannot see events and variables at the post-purchase checkout, you need to use it to avoid the console message of “Duplicate container installation abandoned” where your code is prevented from loading.

    Another tip is to change your console settings to preserve the log since when you test the upsell, a new page will wipe the console. If your code has errors, they’ll be reported in the analytics-sandbox file of your console.

    Post purchase page in Shopify debugging

    Need Help?

    Want us to do all this for you? We can set up everything in this guide for you and help you with analytics problems.

    Get GA4 in your Shopify store working beautifully with no effort on your part, so you can get on with growing your store. Contact us to discuss.

    Liked this article? Get more free Shopify guides:

    You Might Also Like Learning:

    212 Comments.

    • 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 checkout.shopify.com 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?

      oursite.com (wordpress)
      store.oursite.com (shopify)

      David

    • 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: http://screencast.com/t/33Pg7Fbp

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

          • 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 – https://developers.google.com/analytics/devguides/collection/analyticsjs/linker instead of adding sub domain traffic with custom filters ?

      I have a set up with MY-Domain.com ( as the main site ) and shop.MY-Domain.com 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’, [‘MY-Domain.com’, ‘shop.MY-Domain.com’]);

      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 shop.MY-Domain.com 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 (http://www.lunametrics.com/blog/2013/07/02/jquery-event-tracking-generator-google-analytics/) 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.

      Cheers!

    • 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?

    • FANTASTIC POST JOSH!

      One slight tweak the code I think now should be:

      {% if customer.id %}ga(‘set’, ‘userId’, ‘{{customer.id}}’);{% 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 http://www.domain.com – 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

    • Thanks for this great tutorial. I found that for Product content grouping it’s better to use
      ^.*/products/(.*?)$

      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 (www.mysite.com) should I used the same property when hooking up Shopify on subdomain (shop.mysite.com)?

    • 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: https://business.czarto.com/2016/07/08/shopify-fix-your-google-analytics-product-performance-reports/

      Hope this helps.

      Best,

      Alex

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

      Thanks

      • Hi Dave,

        You might be able to do something like that with Segment.com, 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.

      Thanks,
      Julia

    • 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. –
      https://checkout.shopify.com/. . ./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 checkout.shopify.com 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’?

          Thanks!
          J

          • 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 https://www.simoahava.com/analytics/site-speed-sample-rate-multiple-page-views/ Watch for any changes in pageview and other data in your primary ID.

    • In November, a lot of “Russian websites” like abc.xyz and brateg.xyz began to spam analytics accounts Worldwide. In the language settings of your analytics traffic, you’ll see a message like “Secret.ɢoogle.com 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

      \s[^\s]*\s|.{15,}|\.|,
    • 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’, [‘example-2.com’, ‘example-3.com’] );

      (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?

      regards
      Bob

      • 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):

      mydomain\.com|/checkout

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

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

      .*customdomain\.com.*|.*myshopify\.com.*|\/checkout.*

      That seems to catch all the possible permutations of hostnames (customdomain.com, http://www.customdomain.com, shop.myshopify.com, anydomain.com/checkout, 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 ‘yourstore.com’ 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 mydomain.com 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 checkout.shopify.com, 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.
      Cheers!

      • 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 !!!

      Regards
      Coursecrown

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

      Cheers,

      Diederik

    • 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.
      So,
      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?
      https://support.google.com/analytics/answer/1034342?hl=en
      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).

      Thanks
      Jordy

    • 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.
      Thanks

    • 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, checkout.shopify.com pages, and the thank you page:

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

      Thanks!

    • 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

      .*yourstore.com.*|/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 yourstore.com supposed to mean my main domain? In my case that would be evermix.fm – in the same way that ‘yourstore.myshopify.com’ would be ‘evermix.myshopify.com’ 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:

      .*\/checkouts\/.*\?step=contact_information
      .*\/checkouts\/.*\?step=shipping_method
      .*\/checkouts\/.*\?step=payment_method
      .*\/checkouts\/.*\processing
      .*\/checkouts\/.*\thank_you

    • 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)?

      ^(.*\.|)yourstore\.com$|^(.*\.|)shopify\.com$

      • 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{{ product.id}}_{{product.variants.first.id}}’);
      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 analytics.google.com 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 checkout.shopify.com.* 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 checkout.shopify.com. 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 checkout.shopify.com.* 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 checkout.shopify.com.*
      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 .*yourstore.com.*|/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 checkout.shopify.com.*, 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 checkout.shopify.com.*). 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:

      .*yourstore\.com*|checkout.*|\/checkout.*

      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 checkout.shopify.com 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?

            21098333/checkouts/fa4bea4d9345bc21fe5b55b41584c283?_ga=2.167710136.742025126.1530524738-829901770.1525783637%26_gac%3D1.251407922.1528903622.EAIaIQobChMIssDH4_nQ2wIVQrHtCh0MRAPfEAQYBSABEgJ0DfD_BwE

            21098333/checkouts/fa4bea4d9345bc21fe5b55b41584c283?previous_step=shipping_method&step=payment_method

            • 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 shop.website.com and a http://www.website.com. Do I include the sub domains in the linker code?
      gtag(‘config’, ‘UA-XXXXXXXXX-1’, {
      ‘linker’: {
      ‘domains’: [‘www.website.com/’, ‘shop.website.com’]
      }

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

      Thanks!

    • 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 http://www.mysite.com/collections/frontpage/products/beachball 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 pay.shopify.com in the referral exclusion list.

      • Hello,
        I added pay.shopify.com 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
      Wes

    • 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.
      https://checkout.shopify.com/%5BSTOREID%5D/orders/XXXXXXXXXXXXXXXXXXXX

      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
      https://support.google.com/analytics/answer/6223409?hl=en

    • 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?
      Thanks!

      • 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?
      https://help.shopify.com/en/themes/development/layouts/checkout

      Many thanks
      Sam

    • 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:
      {“shopId”:2452451,”isMerchantRequest”:true,”themeId”:167043090,”themeCityHash”:7191376443778836286}}
      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 (domain.com and domain.myshopify.com), 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 myshopify.com 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 yourdomain.com and shop.yourdomain.com? 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.
      Charlie

      • 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!

      Best,

      C

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

      Thanks!

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

      Example:

      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.
      However,
      “Edit each Buy Button code to replace yourstore.myshopify.com with yourstore.com” – I am missing something, because this obviously does not work, changing this:
      https://yourstore.myshopify.com/cart/21070443539140:1?channel=buy_button
      to:
      https://yourstore.com/cart/21070443539140:1?channel=buy_button

      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 portal.afterpay.com 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.