In this blog post we’ll cover the step by step on how to set up Google Analytics 4 with Shopify in order to be able to track both purchases and revenue for your Ecommerce store.

Setting up Google Analytics 4 is more important than ever, since Google will stop supporting Universal Analytics in July 2023, while this date may seem far away, it is important to remember that you need various months of user data in order to effectively run all kinds of retargeting campaigns, as well as to be able to generate customer insights from your data to the fullest.

Step By Step Overview

  1. Log in to your website’s GA4 property.
  2. Locate the website data stream.
  3. List as an unwanted referral.
  4. Copy the global site tag code.
  5. Log in to your Shopify partner store.
  6. Locate the theme.liquid file.
  7. Paste the global site tag code inside the theme.liquid file.
  8. Locate the store checkout settings.
  9. Copy the custom ecommerce tracking code.
  10. Paste + slightly modify the custom code under additional scripts – order status page.

Step by Step: Google Analytics 4

In the following 7 steps you will learn how to locate the GA4 Tag code which you will use inside your Shopify store. You will learn the importance of including as an unwanted referral.

  1. Locate your GA4 property. 
  2. Click on settings (bottom left corner) then click on Data Streams.
  3. Click on the website’s data stream.
  1. Click to copy the Global Site Tag.
  2. Click on more tagging settings.
  1. Click on “List Unwanted Referrals”.
  1. Add using the match type shown in the screenshot.

Adding as an unwanted referral is important because once a user completes a purchase, when you are evaluating where that user came from before purchasing, it will say Shopify and not the actual site they came from. This might cause you to miss key websites driving traffic to your ecommerce site. 

We recommend you include all payment processing platforms as unwanted referrals. 

Step by Step: Link Google Analytics 4 with Shopify

Now you will add your GA4 Tag code to your Shopify store.

  1. Log in to your Shopify partner store, and on the left navigation bar under Online Store click on Themes.
  2. Click on Actions and then on Edit Code.
  3. Locate the theme.liquid file
  1. Paste the Global site tag code you copied from the GA4 property -> Be sure it is below the <head> tag of the HTML code.

Note: If there is some other <script> right below the <head> tag. You can paste the gtag code below it (as shown in the image)

Step by Step: Shopify Revenue Tracking

Now that you have correctly linked GA4 to Shopify, it is time to add some a piece of tracking code in order for purchase revenue values to appear in your GA4 property.

  1. Click on settings (bottom left corner) and then click on Checkout.
  2. Scroll down the page until you see Additional Scripts – Order Status Page -> This section might already include different pieces of code from other services (do not erase any of these).
  1. Go to this site and copy the revenue tracking code. The complete tracking code is also right below.
  2. Paste the code under Order Status Page -> You can paste it under all other pieces of code.

9. Modify the 2 parts of the code with your Google Tag ID

Final Step: Verify That Purchase Data Is Being Recorded

Once the 2 pieces of code are installed, wait around 24 hours, and then the easiest way to verify that purchases and revenue are being tracked correctly is by looking at the monetization tab in Google Analytics.

  1. Click on Monetization – Ecommerce purchases
  2. Verify the number of Ecommerce purchases and Item revenue under these columns.

That is it for today, hopefully you found this step by step guide easy to follow and were able to correctly link your Google Analytics 4 property with your Shopify store.