Google Tag Manager on Shopify: custom pixel setup
How Google Tag Manager runs on Shopify today: as a custom pixel in Customer events, fed by Shopify events, with checkout coverage and no duplicate tags.
By DATALYR · · 4 min read
Contents
Where GTM lives on Shopify now
On Shopify, Google Tag Manager runs as a custom pixel, added in the Customer events section of the Shopify admin. Shopify says GTM is available to all stores through a custom web pixel, and that pixel can see checkout and Thank you page events that theme code never could.
The old pattern of pasting the GTM container into theme.liquid and the checkout's additional scripts no longer covers checkout. Shopify has moved checkout tracking to customer events, so a GTM setup that predates that change needs to be rebuilt rather than patched.
How a GTM custom pixel gets its data
A custom pixel runs in a sandbox, so GTM cannot read the page's DOM or the theme's dataLayer the way it used to. Instead, the pixel code subscribes to Shopify customer events with analytics.subscribe and pushes each one into window.dataLayer. GTM triggers then fire on those event names.
Shopify's tutorial follows exactly this shape: paste the container's head snippet into a new custom pixel without the script tags, push events such as product_viewed into the dataLayer, and create matching custom event triggers in GTM. Shopify notes that at least one tag and one trigger must exist in GTM before any data moves.
Custom pixels load in what Shopify calls a lax sandbox, and Shopify warns that not all pixel functionality works there. Some automatic GA4 behaviour, such as outbound click tracking, has to be rebuilt as custom events, and page URLs can include sandbox details unless you publish your own page_location.
- Map each Shopify event you need: page_viewed, product_viewed, product_added_to_cart, checkout_started, payment_info_submitted, checkout_completed.
- Pass the order ID from checkout_completed as the transaction ID for GA4 and as the order ID for Google Ads.
- Test with the Shopify Pixel Helper. Shopify notes Tag Assistant's troubleshoot feature does not work with custom pixels.
From Shopify event to GTM tag
1. Shopify
checkout_completed
Published by Shopify on the Thank you page.
2. Custom pixel
dataLayer.push
Your code copies the fields GTM needs.
3. GTM
Custom event trigger
Fires the GA4 or Google Ads tag.
Avoid counting every order twice
Most broken GTM setups on Shopify count too much, not too little. Shopify warns that adding Google Analytics through GTM alongside its built-in integration can result in duplicate tracking. The same is true for Google Ads tags added in GTM while the Google & YouTube app also tracks conversions.
Illustrative example. A store takes 120 orders at an $80 average, so $9,600. GA4 is connected through the Google & YouTube app, and a GTM custom pixel also sends purchase. If both send the same transaction ID, Google Analytics deduplicates them. If one sends the order number and the other the order ID, GA4 records 240 purchases and $19,200, double the real figures.
Pick one owner for each destination. If the Google & YouTube app owns GA4, GTM should not send GA4 purchase. If GTM owns Google Ads conversions, turn off the app's conversion tracking for the same action.
What server-side tagging changes
Server-side GTM moves tag execution to a server container you host. The browser sends one stream to your server, and the server forwards it to Google, Meta or others. It can reduce the number of third-party scripts in the browser and give you control over which fields leave your server.
It does not change where the data starts. On Shopify, a server container still receives its checkout events from a custom pixel, so the same consent rules and the same sandbox apply. A server container also has to be hosted and maintained.
The order itself is a different source. Shopify sends paid orders and refunds to an app's server through webhooks, independent of the browser. That is the record to trust for revenue.
When you do not need GTM at all
If GTM exists only to send purchases to ad platforms, you can drop that part. DATALYR installs on Shopify with an App Embed and a Web Pixel, receives paid orders and refunds from Shopify, links each order to the visit and ad click, and sends the conversion to Google Ads, Meta, TikTok and others from one rule per destination.
For Google Ads, DATALYR uploads to a conversion action created as Import from clicks, with the gclid, or with a hashed email or phone when the click ID is missing. Keep GTM for site tags you still need, and remove any GTM tag that sends the same purchase to the same destination.
Related articles.
Tracking ·
Server-side tracking: architecture, responsibilities and limits
Understand what moves to the server, what still depends on browser identity, and how to verify one conversion without creating duplicate events.
Commerce ·
Shopify conversion tracking: reconcile orders, refunds and ad delivery
Verify Shopify order capture, campaign identity, transaction revenue and destination delivery without counting the same purchase more than once.
Google Ads ·
Google Ads server-side tracking: setup and verification
Choose the right delivery path, connect the intended Google Ads account, and verify one conversion from its source event through reporting.
