GA4 PageView Event on Shopify using GTM

by ShahzadaAliHassan - 31st October 2023


Setting up your Shopify store with Google Analytics 4 (GA4) is essential for keeping track of your site's performance and user behavior. Leveraging the power of Google Tag Manager (GTM) simplifies this process. Here's how you can integrate them seamlessly.

Initial Steps: Setting Up Google Analytics and Tag Manager Accounts

  1. If you've already set up your Google Analytics and Google Tag Manager accounts, you can skip to the next section. If not, you'll need to create your Google Analytics and Google Tag Manager accounts.
  2. Ensure that you have the Google Tag Assistant Chrome extensions installed.

Installing the Google Tag Manager (GTM) Container on Shopify

  1. Log in to your GTM account.
  2. Navigate to the Admin section and select Container Settings.
  3. Under the install section, you'll find two tracking snippets. One is for the <head> and the other is for the <body> section of your site.
  4. Copy the tracking code for the <head>.
  5. On your Shopify dashboard, navigate to Online Store > Themes.
  6. Click on Edit Code and locate the theme.liquid file.
  7. Find the <head> tag and paste the GTM tracking code you copied.
  8. Return to GTM and grab the tracking code for the <body>.
  9. Back in the theme.liquid file, search for the <body> tag and paste the second tracking code in the next line.
  10. Save your changes.

OptionalClick on 'format' to pretify the code, to ensure it's readable.

Verifying GTM Installation

  1. Visit your Shopify store.
  2. Use the Google Tag Assistant Chrome extensions to check if GTM is correctly implemented. It should indicate that a GTM container has been found on the website.

Integrating Google Analytics 4 (GA4)

  1. In your GA4 account, click on Admin located at the bottom left.
  2. Go to Property Settings > Data Streams.
  3. Locate the relevant data stream (e.g., Web for Shopify) and copy the Measurement ID (G-XXXXXXXX).
  4. Return to your GTM workspace.
  5. Navigate to Variables and create a constant variable named "GA4 Measurement ID" with the copied ID.
  6. Now, go to Tags > New.
  7. Select Google Tag as the tag type.
  8. Insert your "GA4 Measurement ID" variable in Google Tag.
  9. Save your changes, rename the Tag to "GT GA4 Configuration Tag" and preview the workspace to ensure everything is functioning correctly.
  10. If all goes well, GA4 should now be capturing data from your Shopify store!

TipRemember to periodically check both your GA4 and GTM accounts to ensure data is being captured accurately and to leverage the insights gained for business growth.


Integrating Google Analytics 4 with your Shopify store using Google Tag Manager is a straightforward process. By following these steps, you'll be well on your way to gaining valuable insights about your store's performance and user behavior.

Other Related Blogs

A Comprehensive Guide on Begin Checkout Conversion Tracking on Google Ads and Shopify

Google Ads Dynamic Marketing stands out for its ability to utilize e-commerce event data, such as item details, IDs, and names, to create targeted and efficient marketing strategies. By the end of this guide, you'll understand how to set up these conversion tags and send dynamic parameters back to Google Ads.

WooCommerce Ga4: Begin Checkout Enhanced Ecommerce Event using GTM and DataLayer (Part 4/5)

The "Begin Checkout" event is triggered when a user moves from the cart page to the checkout interface, indicating they're beginning the process of completing a purchase. This event captures critical actions such as clicking on "Proceed to Checkout" or accessing checkout directly via checkout links.

Optimizing Shopify Sales: Mastering Purchase Event Tracking with TikTok Pixel and Google Tag Manager

Discover the key strategies for proficiently tracking Purchase events in Shopify using Google Tag Manager, a crucial tactic for any online retailer aiming to enhance their e-commerce platform. This insightful blog post delves deep into the nuances of Purchase event tracking, offering essential tips for leveraging TikTok Pixel to gain a comprehensive understanding of customer purchase patterns. Learn how to effectively capture and analyze these pivotal moments in the customer journey, ultimately driving sales growth and refining your targeted marketing approaches.

TikTok dynamic URL UTM parameters for Tracking User's acquisition

To track the traffic acquisition for tikTok ads on google analytics for iOS14+ users. To track the performance of the tikTok ads in UA or GA4 using custom reports and secondary dimensions.