Shopify GA4 page_view tracking with GTM
Track Shopify page views with Customer events and GTM, send the shopper's page URL to GA4 and check for duplicate page_view events.
Shahzada Ali Hassan, founder of Crisperchecked against 11 sources
The short answer
Track Shopify page views in GA4 by mapping the Customer events page_viewed event to a GTM page_view tag. Shopify's tutorialhelp.shopify.com explains that sandbox URLs may otherwise appear in GA4. This guide is for store owners who need a custom pixel with the shopper's page URL and checks for duplicate page views.
- If Google & YouTube already sends correct page views, inspect it before adding this setup.
- Use
page_viewedas the trigger andpage_viewas the GA4 event. - Disable automatic page views before sending them manually.
- Steps and settings checked against Google and Shopify documentation on 25 October 2026.
FREE CALL
30 MINMeta stopped counting your leads? Get them counted again.
- Pick a time
Check your Meta account with Hassan- See what to do next
On a free 30-minute call, Hassan checks your Meta account with you and shows you what to do next.
Not ready to talk? Run a free check
01How do I track Shopify page views with GTM?
Record the URL and title of two development-store pages before testing the pixel. Compare them with the page fields in Shopify's event-context mappinghelp.shopify.com so you can identify each received page view.
The video shows the older theme-only installation; the written steps use Customer events for this custom pixel method.
02What do I need before setting up page_view?
Have a development store, a test GTM container and the intended GA4 web-stream Measurement ID ready. The native Shopify GA4 integration is the simpler route if you do not need custom event mappings.
This is the wrong fix when page views already arrive correctly from another integration. Shopify's custom pixel instructionshelp.shopify.com say to remove or modify overlapping pixels so events are not counted twice.
03Where do I install GTM for a Shopify custom pixel?
Put the JavaScript loader inside Settings > Customer events, alongside the page-view subscription.
1. Create the development-store pixel
- On a development store, open Settings > Customer events and add a pixelhelp.shopify.com.
- Paste the GTM head snippet without its HTML script tags, as Shopify's GTM tutorialhelp.shopify.com says.
- Use the ID of a test container that only your development store loads.
- Put the subscription below in the same pixel.
- Review Customer privacy permissionshelp.shopify.com against the store's consent plan.
Done when the saved pixel contains your test container ID, the subscription and the intended privacy settings.
2. Add the page-view subscription
This subscription follows Shopify's page-view mappinghelp.shopify.com and reads page metadata from the event contextshopify.dev.
- Append the subscription below after the loader.
- Save the pixel.
window.dataLayer = window.dataLayer || []; analytics.subscribe("page_viewed", (event) => { window.dataLayer.push({ event: "page_viewed", page_location: event.context.document.location.href,
4 more lines of JavaScript
- Copy and download
- Emailed to you
Unlock this snippet
Two details, and the full code is yours
No account needed. Unlock once and every snippet on the blog opens.
Done when the saved pixel contains one page_viewed subscription.
04How do I check the Shopify page-view subscription?
Use Shopify Pixel Helper to inspect the event and its page context.
3. Test the pixel
- Connect the saved pixel on the development store.
- Choose Test. Shopify Pixel Helperhelp.shopify.com shows the subscribed
page_viewedevent and any code errors. - Perform the matching store action with consent granted.
Done when that event has a green dot and its payload matches the action.
This step checks the subscription only; test GA4 receipt after publishing the debug-enabled test version below.
05How do I configure the GA4 page_view tag?
Initialize the Google tag, turn off automatic page views for this manual setup, then send page_view from the Shopify event.
4. Prepare the Google tag
Google's setup guidesupport.google.com documents the Google Analytics destination and the alternate Google tag method.
- Reuse the store's Google tag and GA4 web stream.
- For Google's alternate methodsupport.google.com, enter the stream's Measurement ID as Tag ID.
- Give that Google tag an Initialization trigger.
- Set
send_page_viewto false in the Google tag's Configuration settings. - Turn off page views based on browser-history changes in the test stream's Enhanced measurement settings.
Google's manual page-view guidedevelopers.google.com requires disabling automatic page views to avoid duplicates.
Done when the saved ID matches the intended stream and both automatic sources are disabled for the test setup.
5. Map the page fields
- Create Data Layer Variablessupport.google.com, which read named values from the data layer.
- Choose Version 2 for nested fieldssupport.google.com.
- Enter the paths below.
- Create a Google Analytics: GA4 Eventsupport.google.com tag.
- Enter the intended Measurement ID.
- Set Event Name to
page_view. - Map each table row in Event Parameters.
- Attach the
page_viewedCustom Event trigger. A trigger is the condition that runs a tag. - Save the tag.
page_location
- Data Layer Variable path
- page_location
- Check
- The shopper's full page URL
page_title
- Data Layer Variable path
- page_title
- Check
- The page title from the event
page_referrer
- Data Layer Variable path
- page_referrer
- Check
- The referring document from the event
Done when each saved variable has the correct path, and reopening the tag shows that event name, stream, parameters and trigger.
6. Enable debug mode and publish the test version
Changes saved in a workspace do not run yet. Google sayssupport.google.com you need to publish workspace changes to make them operational.
- Before publishing, open the GA4 Event tag in the development-only container.
- Add
debug_modewith valuetruein Event Parameters, following Google's DebugView instructionssupport.google.com. - Save the tag settings.
- Open the test container that only your development store loads.
- Select Submit, then choose Publish and Create Version.
- Name the version and publish.
Do not publish to a container your live store loads; move the tested setup there through your normal release process.
Done when reopening the tag shows debug_mode set to true in the published version, the test container's Versions list shows your version as published and the pixel code loads that container's ID.
7. Exercise fresh events and inspect receipt
- With the debug_mode test version published, open GA4 DebugView.
- Load two fresh pages.
- Inspect each page_view.
- Remove debug_mode from the non-test configuration.
Done when each navigation has the intended page URL, title and referrer without an unexplained duplicate.
Use Shopify Pixel Helper for the subscription and GA4 DebugView for receipt. Shopify says Tag Assistant's Troubleshoot tag feature is incompatible with custom pixelshelp.shopify.com; a green Pixel Helper dot confirms local execution, not GA4 delivery.
06Why are page URLs wrong or page views duplicated?
Check the URL source and automatic page-view settings before adding tags.
- Using the sandbox URL can put pixel context into reports. Shopify's tutorialhelp.shopify.com shows reading the shopper's URL from the event instead.
- Manual and automatic page views can overlap. Google's instructionsdevelopers.google.com say to disable automatic page views for a manual setup.
- An existing app may own the same event. Inventory the app, theme and custom-pixel senders before replacing one.
07What should I check after page_view works?
Continue with Shopify add_to_cart tracking and checkout entry. Check that each event uses the same intended stream.
08What changed in this guide
- 25 October 2026: Added Customer events page_viewed mapping, manual page_view parameters, automatic-page-view controls and sandbox-aware testing; replaced the old theme-only walkthrough. Moved debug mode before the full test-container publish and required fresh page views for GA4 receipt; labelled the earlier Pixel Helper check as subscription-only. Replaced the repeated opening with an event-specific test instruction.
Sources
11 sources
- 1Shopify's tutorialhelp.shopify.com↩
- 2Shopify's custom pixel instructionshelp.shopify.com↩
- 3the event contextshopify.dev↩
- 4Shopify Pixel Helperhelp.shopify.com↩
- 5Google's setup guidesupport.google.com↩
- 6Google's manual page-view guidedevelopers.google.com↩
- 7Data Layer Variablessupport.google.com↩
- 8Google Analytics: GA4 Eventsupport.google.com↩
- 9Google's ecommerce guidedevelopers.google.com↩
- 10Google sayssupport.google.com↩
- 11Google's DebugView instructionssupport.google.com↩


