- Short answer
- Use an app pixel when possible, else a custom pixel under Settings > Customer events; adding and using custom pixels is unsupported by Shopify.
- Custom pixel
- JavaScript only, loaded in a Lax sandbox that can't read or write the page's DOM
- Theme code
- Not one of the two ways to add a pixel that Shopify's help names
- Additional scripts
- Not supported on the new Thank you and Order status pages
- Double counting
- Look in developer tools for multiple requests to the same analytics endpoint during one page load or event
Which place should your tracking code go?
Tracking code here means a pixel — a JavaScript snippet for marketing and analytics — not a shipment tracking number. Shopify's help names two ways to add one: app pixels, installed through marketing and data collection apps, and custom pixels, added by a developer in the pixels manager. Theme code isn't one of them.
Shopify says to choose an app pixel "when possible", and a custom pixel when no app pixel meets your requirements. App pixels use the Web Pixels API, the officially supported way to integrate web pixels; for Meta, see the ways to connect the Meta pixel.
Managing app pixels takes the Manage and install apps and channels permission.
Four places tracking code can go
| Place | Where you add it | Checkout and Thank you | Consent | Shopify's stance |
|---|---|---|---|---|
| App pixel | Through the platform's Shopify app | Loads on both | You set up consent and opt-outs | Officially supported |
| Custom pixel | Settings > Customer events | Loads on both | Marketing and Analytics by default; data sale | Unsupported; needs JavaScript |
| Theme code | theme.liquid in the code editor | Not a pixel route Shopify names | Bypassing consent violates the Terms of Service | Not one of the two pixel routes; remove old pixel code by hand |
| Additional scripts / checkout.liquid | Old code only | Not supported on the new pages | Consent often not set up properly | Replace with an app pixel, else custom |
Shopify Help Center and shopify.dev, read October 12, 2026.
What a custom pixel can and cannot reach
Under Settings > Customer events, click Add custom pixel and give the pixel a unique name; Add pixel then opens the event editor: paste the code, save, connect. It takes JavaScript only, so strip any HTML and replace script src= with its JavaScript equivalent.
The pixel runs in a Lax sandbox, subscribes to standard events such as checkout_completed, and collects events on checkout and post-purchase pages.
Pixel sandboxes can't:
- scrape the page's DOM or write to it;
- render buttons, forms, banners or modals;
- automatically detect six kinds of data, from page scrolling to mouse movement for heatmaps (for four of them — events, metadata, user information and outbound links from DOM scraping — you can publish custom events as an alternative).
Google Tag Manager can run as a custom pixel, but the tags it loads stay in the same sandbox.
The Manage and add custom pixels staff permission allows adding a custom pixel (see why Customer events can be greyed out).
Shopify states that adding and using custom pixels is unsupported by Shopify and requires JavaScript knowledge, then adds:
Compliance with applicable laws, consents, code security, troubleshooting, and updates are your responsibility.
By default, new pixels require Marketing and Analytics permissions, and new custom pixels qualify as data sale, so they won't run for customers who opted out of data sales unless the pixel supports limited data use. In markets configured to require consent, usually the EEA and the UK, pixels run only with the visitor's permissions.
When does tracking code belong in theme code?
Only when an app or the theme editor can't do the job — Shopify's general rule for editing theme code, which also expects HTML, CSS and basic Liquid. Its pixel help mentions theme.liquid as a place pixels were previously added manually, to be migrated to an app or custom pixel. Shopify's docs name tracking code that can live there: Shopify.analytics.publish() calls in theme.liquid, which publish custom events your custom pixels can read.
Hand-placed code has costs: changes incompatible with a theme update are removed in the updated copy, and snippets that bypass customer consent requirements violate the Shopify Terms of Service.
A Shopify developer guide moves a script into the theme "using a custom Liquid block where possible", yet none of the help and shopify.dev pages we read on theme code, pixels, theme structure, script tags and section settings says, as of October 12, 2026, whether <script> tags are allowed in Custom Liquid. For plain HTML, see how to add custom HTML.
What to do with old tracking code
For non-Plus stores, August 26, 2026 was the deadline to upgrade the Thank you and Order status pages; stores not upgraded by then were upgraded automatically, and Additional scripts for tracking and analytics aren't supported on the new pages. On Plus, checkout.liquid stopped working for the Information, Shipping and Payment steps on August 13, 2024.
Replace old code with an app pixel, or a custom pixel if no app fits. Pixel counts can drop: pixels track only with consent, which old additional scripts and checkout.liquid code often didn't set up properly — more in our checkout extensibility guide.
Remove old pixel code by hand from:
theme.liquid;checkout.liquid(Shopify Plus only);- Additional scripts in your checkout settings.
Shopify gives two timings: remove existing pixels before adding a custom pixel (Manage your custom pixels page), or deactivate an additional script after the pixel is connected and tested (additional scripts page).
To catch double counting, open your browser's developer tools and look for multiple requests to the same analytics endpoint during a single page load or event.
This page was written by AI. Separate AI agents that did not write it check its figures and claims against official sources and test its links and interactive tools. A human editor sets the site's editorial direction, topics and rules and checks that pages are complete and display correctly, but does not check their facts or edit their text. Details may change — always confirm critical data at shopify.com.
Editorial Policy