Installing Google Tag Manager on a Shopify store
On Shopify, installing the Google Tag Manager container in theme.liquid no longer covers the whole measurement. Since Shopify moved to its new checkout system, the payment step has to be handled separately through Custom Pixels, in Settings > Customer events.
The situations I handle
- GTM is installed in theme.liquid but no tag fires on the payment page
- You’re not sure if the container is enough on its own or if a Custom Pixel is also needed
- A tag used to work before a Shopify update and stopped reporting since
- You’re migrating from another platform and assume one code location is enough, like elsewhere
- You want to centralise GA4, Ads and Meta through GTM while still covering purchases
How I install GTM on Shopify
-
Installing the container in theme.liquid
I place both GTM code snippets (head and body) in theme.liquid, which covers the catalogue, product pages and cart.
-
Assessing the payment page
Since custom scripts were removed from the payment and confirmation pages, the code placed in theme.liquid no longer loads there: a second mechanism is needed.
-
Creating a Custom Pixel
In Settings > Customer events, I create a Custom Pixel that listens to Shopify events (order placed, add to cart). That pixel runs inside a sandboxed iframe with no access to the parent window, so it cannot push into the theme's window.dataLayer. I load a GTM instance inside the pixel itself, with its own data layer, and that instance fires the checkout-step tags.
-
Matching the data layer across theme and pixel
I match the variables (items, value, currency, transaction_id) between what theme.liquid sends and what the Custom Pixel sends, so both GTM instances, the theme's and the pixel's, report consistent data.
-
End-to-end testing
I place a full test order and check in GTM preview mode that tags fire correctly both on the catalogue and on the order confirmation.
A quirk specific to Shopify
On PrestaShop or WooCommerce, a single code location in the theme is usually enough to cover the whole purchase funnel, including order confirmation. On Shopify, that’s no longer the case since the move to checkout extensibility: Shopify removed the ability to add custom scripts to the payment and confirmation pages, with a 28 August 2025 deadline announced for phasing out legacy customisations.
In practice, a GTM container installed only in theme.liquid keeps covering the catalogue and cart, but loses all visibility on the payment step. That step needs handling separately, through a Custom Pixel in Settings > Customer events, or through the official sales channels depending on the end tool.
Since early 2025, Shopify has also automatically migrated old pixels not configured through the official channels into custom pixels, with Shopify itself flagging a risk of lost measurement while the migration is checked.
Related pages
-
Google Analytics 4 on Shopify
The same checkout constraint applies directly to the GA4 tag.
-
Duplicate stats: the causes
What happens when an official pixel and a Custom Pixel coexist for the same tool.
-
Gap between orders and your measurement tool
Why a gap between real orders and measured conversions stays normal, within limits.
-
Shopify, one of my platforms
The other Shopify topics I deal with day to day.
Describe your need in one minute
A few targeted questions so I can reply with an estimate rather than another questionnaire.