Back to all articles
Photo of Niki, the author of this blog post
Niki · 5 December 2022

Migrating Shopify store from Universal Analytics to Google Analytics 4

Google has announced earlier this year that they will be sunsetting Universal Analytics in the middle of 2023. It’s a big thing for all (ecommerce) business, which use the data collected by UA for their business and marketing decision making process. The most important thing is that the UA will stop processing new hits.

Therefore, Google calls for every business to migrate to new Google Analytics 4 as soon as possible – the earlier you migrate, the more historical data and insights you will have in Google Analytics 4.

Why is this happening?

Since universal analytics were built some time ago, they no longer meet the current requirements of businesses, privacy policies nor the way the data are collected. The measurement methodology has become obsolete, mainly relying on independent sessions and gathering data using cookies.

The newly created event-based measurement model of GA4 can, on the other hand, process data across multiple platforms, doesn’t exclusively rely on cookies, and takes into account user privacy needs.

Here are a couple of highlights of GA4:

  • No more last-click attribution! Understand your marketing efforts and improve ROI with data-driven attribution
  • Get a complete view of your customer journey across touchpoints thanks to event-based measurement (no more data fragmentation by platform nor organization into independet sessions)
  • Privacy is important! Manage and minimise the collection of user-level data (cookies, metadata), while preserving the key measurement functionality.
  • Use sophisticated predictive insights about user behaviour and conversions (based on machine learing)
  • Integrate with other Google products, such as Google ads (use combined data for optimizing your campagigns and tuning your marketing efforts)


  • All standard Universal Analytics properties will stop processing new hits on July 1, 2023.
  • 360 Universal Analytics properties will stop processing new hits on October 1, 2023.
  • You will have access to previously processed UA data for at least six months.

Note: Due to the reasons mentioned above, we recommend that all merchants make the switch to GA4 as soon as possible to build the necessary historical data before UA stops processing new hits.

How to migrate your Shopify store from UA to GA4?

Right now, Shopify supports tracking under UA properties and isn’t currently compatible with GA4. In other words, there’s no UI friendly (no-code) way how to configure GA4 on your Shopify store.

There is no exact date announced by Shopify (unofficialy, the configuration should be released in March 2023), when this will be all set up. Until then, you can either implement the tracking by yourselves (light coding skills will be needed) or wait till Shopify releases a simple no-code option. In the following part of this article, you’ll find out how to install GA4 on your Shopify store:

  • using the Shopify integration (to be done when more information is available),
  • manually,
  • with GTM.

Create a new property and add a data stream

Before installing the GA4 piece of code to your site, you need to set up two important things – a new property and data streams.

Create a new property

  1. Open your GA account and go to Admin → GA4 Setup Assistant, then click the Get Started button. Enabling the GA4 set up assistant
  2. After clicking the button, Google will give you a quick overview of the next steps (what will be set up and what will remain unchanged). An overview of GA4 changes and news
  3. Please, bear in mind that your existing UA property will be unaffected and that your new GA4 property will not be populated with any historical data!
  4. Create the property and continue with the setup.
  5. A new modal window will show up. You need to decide how you want to set up a Google Tag.
  6. In our guide, we will install a new Google Tag (if you wish, you can use a Google Tag you already have). Creating a new Google tag for GA4
  7. The next screen shows two main ways how you can install the Google tag to your store. You can either use an integration (website builders, CMS) or install it manually. The first option doesn’t come into consideration since you can notice that there is no integration with Shopify yet. Therefore, we need to choose the second option – install the tag manually.
  8. When you click the tab “Install manually”, you can see the Google tag piece of code. Google tag GA4 – code snippet.
  9. Click “Done” button. You will redirected to the newly created GA4 property. (You don’t need to save the piece of code, we will access it later when adding a new data stream).
  10. Now, a new property is all set up. Property GA4 is successfully set up.

This was a first step on how to set up the GA4. Now, it’s time to add a data stream.

Add a data stream

To start collecting data, we have one more step to complete. You have probably noticed that we didn’t include the store URL when creating the new property (this step was essential when creating a Universal Analytics property).

The reason is that GA4 collect data across multiple touchpoint and therefore we will be using data streams instead. Each GA4 property can have up to fifty different data streams, which can come from either mobile apps or websites.

  1. To create a data stream, go to the newly created GA4 property → Admin → Data Streams and click the Add stream button. Create a new data stream
  2. Choose a type of the data stream. For the Shopify store, choose Web.
  3. Fill in the store (website) URL, name the stream and choose what you would like to measure on the site. Create a new data stream
  4. You can configure enhanced measurement (e.g. you can decide that you don’t want to measure file downloads or site search. This is up to you).
  5. Create the stream.
  6. A familiar modal window with the Google tag install instruction will show up. Click the “Install manual” tab and keep the tab open.

Install GA4 to Shopify with the Shopify integration

Unfortunately, the integration isn’t ready yet. There have been some unofficial announcements that the Google <-> Shopify integration should be ready in March 2023 (when a new Google App should be launched to the Shopify app store). If you don’t want to wait till then, read more in this guide on how to install the GA4 tag to your Shopify store manually or by using Google tag manager. Unofficial announcement of when GA4 integration to Shopify will be ready.

Update: March 2, 2023

Shopify has announced that Google Analytics 4 will be launching natively through the Google channel app on Shopify in March. To start using GA4 seamlessly, you will need to do the following steps:

  1. Create a new GA4 property together with the data streams in your Google Analytics dashboard.
  2. Install the Google channel app and log in to your Google account.
  3. Go to Online store -> Preferences -> Google Analytics section.
  4. You should see a notice to “Manage pixel here”. Click the button. Set up GA4 on Shopify through Google channel app
  5. In the “Connect a Google Analytics property” section, choose the GA4 property you would like to connect with your Shopify store. Connect GA4 property with Shopify using the native integration
  6. After you connect the GA4 property, you should see a notice that the property has been successfully connected. GA4 property successfully connected to Shopify store

As you can see, the integration is in beta version right now. Therefore you might encounter some issues when trying to connect your GA4 property. Let’s see if there are any more actions merchants will need to do to fully take advantage of the integration.

Install GA4 manually with the Gtag to your Shopify store

  1. After you created a new GA4 property and added a web stream, it’s time to install the Google tag to your Shopify store.
  2. Go to Shopify admin → Online store → Themes → Choose your current theme and click the three dots.
  3. In the dropdown menu, choose edit code.
  4. Find the theme.liquid file.
  5. Add the following code snippet immediately after the <head> element. Don’t forget to replace “XXXXXXXX” with your GA4 measurement ID. (You can also copy the Google tag from the installation instructions in GA).
  1. Visit your Shopify store, make some clicks and go back to Google Analytics.
  2. Click Realtime overview and you should start seeing the data coming through.

Track Ecommerce Data

  1. Then, to track ecommerce data (such as purchase event), you need to add a code snippet in the “Additional scripts” section.
  2. Go to Settings → Checkout and accounts → Scroll down to Order status page.
  3. Insert the following piece of code in the Additional scripts window.

Install GA4 using Google tag manager (GTM)

  1. First of all, make sure that GTM is installed to your store. To learn more about how to install GTM to your site, please visit Google official documentation.
  2. In Google Tag Manager, click “New” to create a new tag.
  3. Name the tag “GA4”.
  4. In the “Tag Configuration” section, select “Google Analytics: GA4 Configuration”.
  5. Enter your measurement ID.
  6. In the “Triggering” section, select “All Pages”. Configure GA4 Tag settings
  7. Verify Google Tag Manager and your GA4 tag is installed correctly in Shopify by using Preview mode in Google Tag Manager.
  8. In Google Tag Manager, click “Submit” to publish your tag.
  9. Visit your Shopify store, click some pages and go back to Google Analytics.
  10. Click Realtime overview to start seeing the data coming through.

Add GTM with data layer to the additional script

  1. Go to Settings → Checkout and accounts → Scroll down to Order status page.
  2. Insert the following piece of code in the Additional scripts window.

Note: This is a basic set up of the data layer. You might need to add some more specifications and edit the code so that the tracking meets your business & marketing goals. Learn more about the data layer from official Google documentation.

Create variables

  1. To pass the details of each purchase to Google Analytic, you will need to create a couple of data layer variables, an event tag (for purchase) as well as a trigger, which fires the event.
  2. To make it easier for you, we’ve pre-defined a container, which you can download and import directly to GTM (including the all pages tag for GA4).
  3. Download the container here.
  4. Please bear in mind that we created a very simple setup, which might need some more customizations (such as adding more variables, editing the variable definitions, and else) so that the settings suit your business needs.
  5. Import the container to your workspace in GTM. Make any changes to the variables, tags or a trigger. Don’t forget to change “Insert Your Measurement ID here” in the GA4 tag configuration Measurement ID field to your GA4 measurement ID.
  6. Preview and submit the changes.

Excluding Shopify checkout page as referral

To make sure that purchases are attributed to the correct marketing channel, you will need to prevent the Shopify checkout pages from showing up as referrals in your reports. To do this, follow the steps below.

  1. Open the web data stream in GA4.
  2. Click “Configure Tag Settings”. Configure GA4 Tag settings
  3. In the Settings section, click the dropdown menu Show all and click List Unwanted Referrals.
  4. Enter the domain of your Shopify store. Configure GA4 Tag settings – excluding Shopify domain

Important note: We described the simpliest solution on how to install GA4 to your Shopify store. You will probably need to make some more customizations, modify the code, add more variables or so, when you’ll be setting up the configuration. Plus, Shopify has unofficially announced that the integration Shopify <-> GA4 should be ready in March 2023. When it’s done, it might happen that some steps will need to be done differently. We’ll update you about that.

Last but not least, we would like to stress out that we don’t support Google analytics. We prefer 100% privacy-friendly analytics platforms such as Plausible Analytics or Simple Analytics. However, since most of our clients use Google Analytics and came to us to discuss the migration to GA4, we decided to write a guide on how to do it.

Have a project in mind?
Get in touch
Drop us an email to

and one of us will get back to you soon.