GA4 PageView Event on Shopify using GTM

by ShahzadaAliHassan - 31st October 2023

Introduction

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.

Conclusion

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.