How to Set Up Google Analytics 4 on Shopify? (e-commerce tracking included)

Erman Küplü
Better Shopify
Published in
4 min readFeb 21, 2021

--

Google Analytics 4 is a new and exciting service that offers many new features and a completely unique approach to reporting and data processing. In this post, I am going to show you how you can set it up for your Shopify store — including the e-commerce data.

I am working on another article on why Google Analytics 4 (GA4) is highly effective for e-commerce stores. For now, we will focus on step-by-step technical setup and validation.

2023 August Update:

The latest resources:

Before we get started, you need to have a GA4 account. If you haven’t created one yet or are unsure about how to move on, you can watch a 3-minute clip from this video where I answer what Shopify store owners should ideally do with GA4. Make your decision, take action and come back here. :)

Step 1: Copy your GA4 Global Tracking Code

I assume you have created your Google Analytics 4 account. Make sure you are logged into your GA4 account, not Universal Analytics. Follow the steps below and copy your global tracking code. It is a global tag so we are going to insert this code on every page of your Shopify store in the next step.

Google Analytics > Admin (Left-bottom) > Data Streams

Google Analytics 4 — Admin Dashboard — Data Streams

You will see two options here: Global Tag — Google Tag Manager. We will go with the Global Tag option in this tutorial. Click on the data stream, choose Global Site Tag, and copy the code.

Google Analytics 4 — Admin Dashboard — Global Site Tag

Step 2: Insert GA4 Global Tag into Shopify Theme

It is time to insert GA4 Global Tag into your Shopify store. As this is the global tag, you are required to insert it on every page of your store. That means we will also need to insert this code into your theme’s global file. Don’t worry; it won’t be that hard. :)

Go to your Shopify Admin > Online Store (Left Menu) > Themes

Next to your active theme, first, click “Duplicate” just to be safe and create a backup. Then click “Edit Code.”

Edit Shopify’s Theme Code

Here you will see the primary file called theme.liquid but if you don’t see it right away, search for it. Click and paste your GA4 Global Site Tag code right below <head> — as seen in the screenshot.

Google Analytics 4 Global Site Tag into Shopify Theme

Step 3: Insert GA4 Global Tag into Shopify Theme

This step will make all the difference. E-commerce tracking and sales reports are dependent on the sales data. This is where things get complicated a little. Don’t worry; we have figured this out. It is much easier if you complete this step relying on my tutorial video. As we have already covered the global tag, you can start from the second section.

The steps will be:

  • Getting your e-commerce Tag from the Analyzify GA4 Wizard.
  • Pasting that into your checkout page.

Step 4: Validate the Data

Jump into the last section of the video and validate/debug your setup. You should be seeing your test sale in the real-time report and it will take some time for that to be visible in the e-commerce reports.

Frequently Asked Questions

Q: I’m already using Universal Analytics. Do I need GA4? What should I do?
A: I have answered this question in the video in-depth. Do not touch your Universal Analytics setup and also install Google Analytics. It is great to use them both.

Q: I am using Google Tag Manager. How should I move on?
A: You can still use the tutorial and set up GA4 independent from the GTM installation. Everything will work great. Setting up GA4 with Google Tag Manager is more complex than the plain setup. I recommend you using an app or professional service.

Q: Why do I need Google Analytics 4 for my Shopify store?
A: Google Analytics 4 has many great features. Especially with funnels, data visualization and AI-powered analysis. I will have another article on this topic.

--

--

Erman Küplü
Better Shopify

Learner 🔖 Co-created Analyzify — empowering 600+ #Shopify Merchants with accurate data 🏹 Co-founded Solverhood — completed 400+ projects on #Upwork