[Customer Pixel] How to Configure Google Analytics Page View Event on Shopify Using Google Tag Manager
by ShahzadaAliHassan - 29th August 2024Setting up Google Analytics to track page views on your Shopify store is essential for understanding how visitors interact with your site. This blog post will guide you through configuring a page view event in Google Analytics using Google Tag Manager on a Shopify store. We’ll break down the process into simple steps that anyone can follow, even if you’re new to web analytics.
Table of Contents
- Introduction
- Accessing Shopify and Google Tag Manager Setup
- Creating and Configuring a Google Tag Manager Container
- Connecting Google Tag Manager to Shopify
- DataLayer code for Page View event
- Adding Google Analytics Page View Event
- Creating Tags, Triggers, and Variables
- Verifying Event Firing in Google Analytics
- Summary and Final Steps
Introduction
By the end of this guide, you will know how to configure a Google Analytics page view event using Google Tag Manager on your Shopify store. This will allow you to track visitor interactions, giving you insights into user behavior on your site.
Accessing Shopify and Google Tag Manager Setup
Before we start, ensure you have access to the Shopify backend and the Google Tag Manager (GTM) account you will use.
- Shopify Access: Log in to your Shopify admin panel. Navigate to Settings > Customer Pixels to ensure you have the necessary permissions to add or modify customer pixels.
- Google Tag Manager Access: If you already have a GTM container, that’s great! If not, create a new container in your GTM account. Make sure you have published access to this container by checking under Admin > User Management.
Creating and Configuring a Google Tag Manager Container
If you need to create a new container:
- In your GTM account, click Create Container.
- Name the container appropriately (e.g., "Shopify Store Container").
- Select Web as the platform.
- Hit Create.
Make sure you also have editor or admin access to your Google Analytics account to configure the necessary settings.
DataLayer code for Page View event
Now, we need to ensure that the GTM container is firing correctly on your Shopify store.
- Go to your GTM container and find the configuration code.
- Copy the code snippet for both the
<head>
and<body>
sections. - In Shopify, navigate to Settings > Customer Pixels, click on Add Custom Pixel, and paste the GTM code in the relevant section.
- Ensure your pixel settings are configured correctly: set permissions to "Not Required" and indicate that the data sale is "Not Selected".
Once configured, click Save and then Connect to link your GTM container with the Shopify store.
Understanding Sandbox Environment and Customer Pixels
Shopify’s customer pixels operate in a sandbox environment, meaning they run within an iframe, limiting their interaction with the parent site. This setup enhances security but restricts traditional tracking methods like using liquid files.
You can verify if your GTM container is firing correctly by using the Google Tag Legacy Assistant Chrome extension. Note that the standard GTM preview/debug mode does not work with Shopify’s sandboxed customer pixels.
Adding Google Analytics Page View Event
Next, let’s add the Google Analytics page view event to your GTM container:
- Go back to your GTM container and navigate to Workspace.
- Create a new tag, trigger, and variable for the page view event.
- For the tag:
- Select New Tag and choose Google Analytics: GA4 Configuration.
- Set it to fire on All Pages.
However, since we are working with Shopify’s custom event, the process will differ slightly.
- Instead of the standard setup, configure the tag to fire based on the custom events created in the earlier steps.
Creating Tags, Triggers, and Variables
For the custom page view event:
- Copy the trigger name related to the page view event (e.g., "pageView").
- In GTM, go to Triggers > New and select Custom Event.
- Paste the trigger name and save it.
- Next, create a constant variable in GTM to store your GA4 measurement ID.
Finally, create a configuration tag in GTM to fire the page view event.
Verifying Event Firing in Google Analytics
To verify if your tag is working:
- Go to your website’s backend.
- Open the Network tab in your browser’s developer tools.
- Filter for requests named "collect" and refresh the page.
- You should see requests sent to Google Analytics indicating that the page view event has fired.
You can also check the real-time reports in Google Analytics to confirm the event was logged.
Summary and Final Steps
In summary, you’ve configured a Google Analytics page view event using GTM on your Shopify store. The steps involved creating a GTM container, connecting it to Shopify via customer pixels, and setting up tags, triggers, and variables to track page views. Remember to replace the measurement ID with your GA4 ID when using pre-configured GTM containers.