Back

Complete Guide to Understanding and Setting Up GA4 for Shopify

Data utilization plays a vital role in the success of any ecommerce brand. Knowing who your customers are and how they interact with your brand can give you a lot of insight to grow your customer base and stop churn. 

Google Analytics 4, or GA4, is an advanced web analytics tool that can answer all your questions for your ecommerce brand. 

By implementing GA4, you can view and analyze data relevant to your ecommerce products, like who's buying your product, from which country they belong, the total number of purchases from each country, and much such vital information. 

Plus, if you have been using Universal Analytics, know that Google will discontinue it from July 1, 2023. 

Understandably ecommerce business needs to make the shift. 

But getting GA4 on Shopify can get frustrating because the implementation steps are entirely different from what you have been familiar with Universal Analytics. 

What is GA4 for eCommerce? 

If you're unaware, GA4 is the latest version of Google's web analytics platform. It is designed to give ecommerce businesses more powerful and flexible insights into their website traffic and user behavior. 

GA4 uses a new event-based data model allowing more comprehensive tracking of user interactions and engagement across various digital channels, including mobile apps and websites.

How is GA4 different from Universal Google Analytics? 

Compared to its predecessor, Universal Analytics, GA4 offers several new features, including a more intuitive interface, AI-powered insights, cross-device and cross-platform tracking, and better data privacy controls. 

It also allows for more granular data collection and analysis, which can help businesses gain a deeper understanding of their customers and improve their marketing strategies.

Some of the new key features that you will see in GA4 are:

  • Predictive analysis powered by Machine Learning and Artificial Intelligence
  • Creating custom reports (tables or visualizations for cohorts, paths, funnels, or segments)
  • It's empowered to collect events automatically from scrolls, video views, first-time visits, etc. 
  • It can collect up to 30 conversions and 300 events
  • It's up to you to choose your attribution model 

Basic GA4 configuration for Shopify stores  

GA4 has some cool features, but to start using them and reap benefits from them, you need to do the basic GA4 configuration, add the purchase data layer, and then a product view layer. Here's a step-by-step guide.

There are two ways to configure GA4 on your Shopify site:

  1. Global Site Tag (gtag.js)
  2. Google Tag Manager (GTM)

You must collaborate with your developer if you're using the first method. Here's a helpful document that is geared toward the developer community

If you're using Google Tag Manager, here's what you need to do: 

Basic GA4 configuration for Shopify stores

Set up a new GA4 property in your Google Analytics account if you haven't already done so.

  • In Google Tag Manager, create a new tag and choose "Google Analytics: GA4 Configuration" as the tag type.
  • Enter your GA4 Measurement ID in the "Measurement ID" field. You can find this in your GA4 property settings.
  • Choose the appropriate event that will trigger the tag, such as a page view or a click event.
  • Save the tag and publish the changes to your Google Tag Manager container.
  • Once the tag is set up and published, it will send data to your GA4 property according to the configuration specified in the tag. You can then use the GA4 reports to analyze and understand user behavior on your website or app.

Purchase data layer

The Purchase data layer code is responsible for driving conversions and sales revenue. When a customer completes an order, this layer passes variables to Google Tag Manager. There are four steps to add a purchase data layer. These include:

1. Adding the code to the checkout page

Create a purchase data layer code and copy it to the checkout page on your Shopify site. Click on the admin settings. Scroll down to the order status page section and add the code to the additional scripts section. Save it. 

Purchase data layer - GA4 for Shopify

2. Creating a custom event

  • If you haven't already done so, set up a new GA4 property in your Google Analytics account.
  • In Google Tag Manager, create a new tag and choose "Google Analytics: GA4 Configuration" as the tag type.
  • Enter your GA4 Measurement ID in the "Measurement ID" field. You can find this in your GA4 property settings.
  • Choose the appropriate event or trigger that will trigger the tag, such as a page view or a click event.
  • Save the tag and publish the changes to your Google Tag Manager container.
  • Once the tag is set up and published, it will send data to your GA4 property according to the configuration specified in the tag. You can then use the GA4 reports to analyze and understand user behavior on your website or app.
Creating a custom event - GA4 for Shopify

3. Creating a data layer variable

Come back to your GTM workspace and choose the variables that you have defined previously or built-in variables. Then add the data layer variable option. 

Note, that your data layer variable option should match with your data layer. Repeat the process for all the selected variables. 

4. Creating a new tag in Google Tag Manager

To create a new tag in the Google Tag Manager, click on "Variables" in the left-hand navigation and click on the "New" button to create a new variable. Select the appropriate variable type based on the data layer variable you want to create. 

For example, if you want to create a variable for the "product name" data layer variable, you would select the "Data Layer Variable" type. Enter the name of the variable in the "Variable Name" field. Enter the name of the data layer variable in the "Data Layer Variable Name" field. Set any additional configuration options as needed and save. 

Once you have created the data layer variable, you can use it in your tags and triggers within Google Tag Manager. For example, you could use the "product name" data layer variable in a tag that sends ecommerce data to Google Analytics to track which products are being viewed or added to the cart.

Product view layer 

To get the product level details in Google Tag Manager, add another layer called the Product view layer. This layer will be added to the Shopify theme.liquid file. Then add a data layer code, create a custom event, create data layer variables, and create a new trigger in GTM.

Setting up GA4 on Shopify 

Setting up GA4 on Shopify can seem overwhelming, but here’s a step-by-step guide to help you get started.


  1. Add GTM to Shopify. You can skip this step if you have already set up GTM on your Shopify. 
  2.  Have a Shopify Purchase data layer
  3. In the next step, visit the Shopify Admin page, go to settings, checkout, order status page, and additional scripts, and paste the code below your GTM container code. 
  4. Now add the data layer to the product page and follow steps 1-4. But don't complete the GTM action, which you will do in the next step. Now your data layer is added to your Shopify store.
  5. Now it's time to download your GTM container, which you will do with your Google Tag Manager. Create GA4 tags and variables for product view, triggers, and purchase events. This is a complex and time-consuming process, but you may take the help of XgenTech to fasten up the process.
  6. In the next step, import the GTM container you downloaded previously and add your GA4 measurement ID.
  7. It's time to validate and test the data and the setup you have done so far. Use the Google tag manager Preview mode and tag assistant. 

New GA4 eCommerce dimensions and metrics for online businesses  

Item affiliation

Item affiliation refers to the relationship between the primary product being purchased and any additional or complementary products included in the same transaction.

For example, if a customer purchases a pair of shoes (the primary product) and adds a pair of socks (the affiliated product) to their shopping cart before checkout, the item affiliation would be recorded in GA4. This data helps you gauge which products are most frequently purchased together to optimize your product offering strategy. 

Item variant

Item variant is a specific variation of a product sold in an ecommerce transaction. 

For example, a clothing retailer may sell a t-shirt in several different colors, and each color would be considered a separate item variant. Tracking this metric in GA4 can help sellers identify popular variants and analyze the performance of specific variants over time.

Items added to the cart

When a user adds an item to their cart, a "Items added to cart" event is triggered and sends data to GA4, including information such as the product ID, name, and quantity added. This data can then be used to analyze user behavior and track the effectiveness of marketing campaigns.

Items checked out

This event is part of the enhanced ecommerce tracking feature in GA4, which provides more detailed information about user behavior on ecommerce sites than the previous version of Google Analytics. When a user initiates the checkout process, a "Items checked out" event is triggered and sends data to GA4, including information such as the product ID, name, and quantity being checked out. 

Items clicked in the list

This event is triggered when a user clicks on an item within a list. Useful data like list name, the position of the item within the list, and the product ID and name are sent to GA4.

Items clicked in promotion

When a user clicks on an item within a promotional element, such as a banner ad or product listing on a sale page, a "Items clicked in promotion" event is triggered and sends data to GA4. This data helps marketers to gauge which ads are most effective and driving clicks for them.

Items viewed

An event is triggered when the user views a product. Note that "Items viewed" events may be triggered multiple times for the same product when a user views a product on different pages of a site or app. GA4 includes features to help deduplicate these events and provide more accurate user behavior reporting.

Shipping amount

The "shipping amount" parameter is a value that indicates the amount of money charged for shipping and handling associated with a specific transaction.

When a transaction occurs, GA4 records the total revenue generated from the sale, which includes the cost of the products purchased and any additional charges such as taxes, fees, and shipping and handling costs. 

Shipping tier

This parameter can be included in events like "Purchase" or "Refund." This parameter indicates the level of shipping service chosen by the customer for a given transaction. Shipping tiers can vary depending on the ecommerce business and the shipping options available to customers. For example, a business might offer standard, expedited, and overnight shipping options with different prices and delivery times. 

Tax Amount

Tax amount records the amount of tax charged or refunded for any transaction on your Shopify site. Note that to track tax amounts in GA4, the ecommerce tracking feature must be configured appropriately and implemented on the site or app. Additionally, adjusting the tracking code or parameters may be necessary to ensure that tax amounts are recorded accurately and consistently.

New naming conventions on GA4 for eCommerce 

Google has also renamed several metrics:

  • Add to carts (previously called Add-to-carts)
  • Item-list click events (previously called Item list clicks)
  • Item-list view events (previously called Item list views)
  • Item view events (previously called Item views)
  • Items purchased (previously called Item purchase quantity)
  • Promotion clicks (previously called Item promotion clicks)
  • Promotion views (previously called Item promotion views)

Conclusion 

The new GA4 has a lot of new features and holds a lot of potential when done right! 

You can set it up yourself anytime, but if you find it too overwhelming, reach out to XgenTech Shopify experts today

More reading...

Everything About Shopify
July 25, 2024

What is Shopify and How Does it Work ...

Cornerstone Shopify Theme
July 19, 2024

Shopify Theme Review: Detailed Look I...

Shopify Summer Editions '24: New Features & Updates
July 12, 2024

Shopify Summer Editions '24: Exciting...