Shopify GA4 page_view tracking with a custom pixel
Set up Shopify page_view tracking through Customer events and GTM, with the event payload, GA4 parameters and test checks.
Shahzada Ali Hassan, founder of Crisperchecked against 14 sources
The short answer
Track Shopify page views by mapping page_viewed to a GA4 page_view tag in GTM. Shopifyshopify.dev supplies the page context for this event. This guide is for store owners and implementers maintaining a custom pixel, with a development store available for testing.
- Use
page_viewedas the Shopify sourceshopify.dev. - Set the GTM trigger to
page_viewin this example. - If an app already sends
page_view, inspect it before adding a second sender. - Steps and settings checked against Shopify and Google 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 in GA4?
Read the storefront location and title from event.context.document, using Shopify's page_viewed fieldsshopify.dev. Shopify warns that automatic URL detection can see the sandbox URLhelp.shopify.com, so compare the logged URL with the page you visited.
The video shows the older configuration and testing method; the written steps below use the current Google tag and Shopify Pixel Helper workflow.
Use a development store, a dedicated GTM test container and a test GA4 web stream. Shopify suggests testing pixels on a dev storehelp.shopify.com before adding them to a live store. Use begin_checkout setup when checking the rest of this tracking setup.
02What do I need before adding a custom pixel?
Have access to Shopify Customer events, your GTM test container and your test GA4 web stream. Shopify warns that overlapping pixels can count events twicehelp.shopify.com; record which app or script already sends page_view.
1. Check the existing sender
- Before changing anything, inspect the installed apps.
- Inspect the custom pixels.
Done when you can name the intended sender of page_view and the test stream that will receive it.
03Which Google tag should I use?
Use the current Google tag for your test web stream. Google's setup guidesupport.google.com describes the Google Analytics destination and the alternate Google tag setup.
2. Confirm the base Google tag
- Reuse the intended test stream configuration.
- For the alternate setup, choose Google tag and enter its tag ID.
- Use the Initialization - All Initialization Events trigger, as described in Google setup guidesupport.google.com.
- For this manual pageview setup, set
send_page_viewtofalsein the test Google tag. - In the test stream's Enhanced Measurement settings, turn off Page changes based on browser history events, as Google's manual-pageview guidedevelopers.google.com instructs.
Done when the saved tag points to the test stream and initializes before the event tag, and both automatic pageview sources are disabled for this test implementation.
04How do I add the custom pixel in Shopify?
Create or extend one custom pixel under Settings > Customer events, following Shopify's setup instructionshelp.shopify.com.
3. Create the pixel in your development store
- Give the pixel a clear name.
- Choose Add pixel.
- Review Customer privacy.
- Select permissions and data-sale settings that match the store's consent plan, using Shopify's settings guidehelp.shopify.com.
Done when the editor is open and those choices are recorded.
05What code sends Shopify page views to GTM?
Keep the GTM loader and event subscription in the same custom pixel. Shopify's GTM tutorialhelp.shopify.com uses the head loader with its HTML script tags removed.
4. Add the loader and subscription
- Add the code below to the custom pixel.
- Replace
GTM-EXAMPLEwith the ID of a test container that only your development store loads. - If this pixel already loads that container, append only the subscription and its logging helper.
- Save the code in the development store.
A callback is the function inside analytics.subscribe that runs when Shopify emits the named event.
// Initialize the dataLayerwindow.dataLayer = window.dataLayer || [];(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f);})(window, document, "script", "dataLayer", "GTM-EXAMPLE");function logEventToConsole_page_view(dataLayerEvent) { const customStyle01 = "color: #FFFF00; background-color: #000000; font-size: 10px; font-weight: bold; padding: 2px 0;"; console.log("%cDataLayer Event: page_view ", customStyle01, dataLayerEvent);}analytics.subscribe("page_viewed", (event) => {
28 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 code contains your test container ID and the page_viewed subscription.
Read the event payload before choosing the GTM variables. Shopify's referenceshopify.dev defines this event's fields; the table shows how this example maps them.
page_location
- Data Layer Variable name
- page_data.url
- Shopify field or calculation
- context.document.location.href
page_title
- Data Layer Variable name
- page_data.page_title
- Shopify field or calculation
- context.document.title
page_referrer
- Data Layer Variable name
- page_data.referrer
- Shopify field or calculation
- context.document.referrer
Google's pageview guidedevelopers.google.com documents page_location and page_title, and its configuration referencedevelopers.google.com defines page_referrer. Map the Shopify context fields explicitly rather than changing browser history.
06Why does Tag Assistant miss my Shopify custom pixel?
Shopify's sandboxhelp.shopify.com isolates pixel code from the storefront. It is not a separate test store: use a development store for these exercises.
Shopify sayshelp.shopify.com Tag Assistant's Troubleshoot tag feature is incompatible with custom pixels. Use Pixel Helper for the Shopify event and GA4 DebugView for receipt; the source log alone does not show that GA4 received it.
07Which variables and trigger does page_view need?
Create a Data Layer Variable for each path in the mapping table. A variable reads the value from the event object; Shopify's GTM guidehelp.shopify.com describes mapping those values into tag parameters.
5. Map the event parameters
- Create a Data Layer Variable for each path in the mapping table.
- Use Version 2support.google.com for the nested paths.
- Give each variable a clear label, such as
DLV - page_data.url. - Enter the exact field path in Data Layer Variable Name, not the display label.
Done when every parameter in the table has a matching variable.
Use a Custom Event trigger, which tells GTM when to run the tag. Its Event name must match the pushed event key, as Shopify's GTM instructionshelp.shopify.com explain.
6. Create the event trigger
- Create a Custom Event trigger.
- Enter
page_viewexactly in Event name, with regular-expression matching off. - Select All Custom Events for this exact event name.
- Save the trigger.
Done when the saved trigger matches the page_view key in the snippet.
08How do I configure the GA4 page_view tag?
Send page_view with a Google Analytics: GA4 Event tag, following Google's event-tag instructionssupport.google.com.
7. Save the GA4 Event tag
- Create a Google Analytics: GA4 Event tag.
- Enter the test stream's Measurement ID.
- Set Event Name to
page_view. - Under Event Parameters, add the table's parameter names, using their Data Layer Variables.
- Attach the
page_viewtrigger and save the tag.
Done when the saved event name, destination and variable mappings match the table.
09How do I test page_view without changing live tracking?
Check the source event and GA4 receipt in the same test session. Google's DebugView guidesupport.google.com lets you inspect received events and their parameters.
8. Prepare the test tag for DebugView
- Open this test GA4 Event tag.
- Add
debug_mode: trueusing Google's debug instructionssupport.google.com. - Save the tag.
Done when the saved test tag includes that parameter.
9. Publish the version in the test container
Changes saved in a workspace do not run yet. Google sayssupport.google.com you need to publish workspace changes to make them operational.
- 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 the test container's Versions list shows your version as published and the pixel code loads that container's ID.
Shopify's Test control opens the pixel for testinghelp.shopify.com. It does not replace the GTM publication step above.
10. Run the event through the test container
- Open Test from the connected custom pixel.
- Grant the planned analytics consent.
- Open a storefront page, then navigate to another page.
- In Pixel Helper, check that
page_viewedappears without an error. - In the test property, open Admin > Data display > DebugView.
- Select your test device and check that
page_viewappears and the parameters match the source values. - Repeat with a different product, quantity or page.
- Exercise the denied-consent path.
- Note both results and whether they match the consent plan.
- Navigate between two known pages and reload one.
- Check that each intended page view has the correct storefront URL and title, without an unexplained second page_view for the same action.
- Remove
debug_modefrom the finished configuration after testing.
Google sayssupport.google.com setting debug_mode to false does not disable debug mode.
Done when Pixel Helper and DebugView show the results above, your notes record both consent results and whether they match the consent plan, each intended page view has the correct storefront URL and title, and debug_mode is absent from the saved configuration.
10What should I check after this event works?
Compare the purchase guide with the same test journey. Keep the source-event and GA4 receipt notes together so another implementer can repeat the check.
11When is this setup the wrong fix?
A second sender, a mismatched trigger or the wrong payload needs a different fix. Check the failing stage before adding tags.
- Another app already sends the same event: Shopify warnshelp.shopify.com that overlapping pixels can double-count it. Identify the existing sender before adding this one.
- The trigger uses a friendly label rather than
page_view: it will not match the snippet's event key. Copy the key into the trigger. - Contact details are mapped into GA4 parameters: Google prohibits sending personally identifiable informationsupport.google.com such as email addresses and personal phone numbers. Map only the fields listed here, and review URLs and titles for personal data.
12What changed in this guide
- 25 October 2026: Corrected the page_view mapping, consent settings, Google tag setup and test procedure. Updated the code and completion checks; the video still shows the older method. Made test-container publication mandatory and replaced the repeated intro with the event-specific next step.
Sources
14 sources
- 1Shopify sourceshopify.dev↩
- 2Shopify warns that automatic URL detection can see the sandbox URLhelp.shopify.com↩
- 3Shopify suggests testing pixels on a dev storehelp.shopify.com↩
- 4Shopify warns that overlapping pixels can count events twicehelp.shopify.com↩
- 5Google's setup guidesupport.google.com↩
- 6Google's manual-pageview guidedevelopers.google.com↩
- 7Shopify's GTM tutorialhelp.shopify.com↩
- 8configuration referencedevelopers.google.com↩
- 9Google's data-layer guidedevelopers.google.com↩
- 10Version 2support.google.com↩
- 11Google's event-tag instructionssupport.google.com↩
- 12Google's DebugView guidesupport.google.com↩
- 13Google sayssupport.google.com↩
- 14Google prohibits sending personally identifiable informationsupport.google.com↩


