How To Set Up Google Analytics 4 With Shopify To Track Purchases & Revenue
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
- Log in to your website’s GA4 property.
- Locate the website data stream.
- List myshopify.com as an unwanted referral.
- Copy the global site tag code.
- Log in to your Shopify partner store.
- Locate the theme.liquid file.
- Paste the global site tag code inside the theme.liquid file.
- Locate the store checkout settings.
- Copy the custom ecommerce tracking code.
- 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 myshopify.com as an unwanted referral.
- Locate your GA4 property.
- Click on settings (bottom left corner) then click on Data Streams.
- Click on the website’s data stream.
- Click to copy the Global Site Tag.
- Click on more tagging settings.
- Click on “List Unwanted Referrals”.
- Adding myshopify.com 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.
- Log in to your Shopify partner store, and on the left navigation bar under Online Store click on Themes.
- Click on Actions and then on Edit Code.
- Locate the theme.liquid file
- 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.
- Click on settings (bottom left corner) and then click on Checkout.
- 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).
- Go to this site and copy the revenue tracking code. The complete tracking code is also right below.
- Paste the code under Order Status Page -> You can paste it under all other pieces of code.
- 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.
- Click on Monetization – Ecommerce purchases
- 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.
Hi there,
Overall, a nice step-by-step overview, thank you.
However, your overview seems to be focused for either one specific theme or the Shopify default themes, of which a majority of shops do not use.
Are you able to provide more details or key ‘sections’ of code to look for when needing to plcae the GA4 monetization tracking into the code? Many themes don’t have the ‘Order status page’, so where to locate the required placement is a bit tricky to do!
Thanks in advance!
Our walk through it not based on any one theme. We have used this method to set up GA4 for all our clients across all plan tiers and even those on an old school custom Shopify plan. The only tweak we make is for our Shopify Plus clients. All Shopify stores should retain the order status page as it is how customers check on the status of their order. You can go to Additional Scripts – Order Status Page to find where to place your code.