Ecom Store Pro

Where do you add tracking code in Shopify: an app pixel, a custom pixel or theme code?

Published ·
At a glance
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

PlaceWhere you add itCheckout and Thank youConsentShopify's stance
App pixelThrough the platform's Shopify appLoads on bothYou set up consent and opt-outsOfficially supported
Custom pixelSettings > Customer eventsLoads on bothMarketing and Analytics by default; data saleUnsupported; needs JavaScript
Theme codetheme.liquid in the code editorNot a pixel route Shopify namesBypassing consent violates the Terms of ServiceNot one of the two pixel routes; remove old pixel code by hand
Additional scripts / checkout.liquidOld code onlyNot supported on the new pagesConsent often not set up properlyReplace 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.

Add custom pixel sits above the Pixels list under Settings > Customer events.

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.
Shopify Help Center — Custom pixels ·

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.

The layout folder in the theme code editor, with theme.liquid open.

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.

About This Article

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

Related questions

Payments & payouts
Can you remove Shopify branding from the Shopify checkout page?

No Shopify logo to remove; on a store with Shop Pay activated, removing Shop's sign-in prompt for all customers means deactivating Shop Pay.

September 21, 2026

Online store & themes
Do Shopify themes update automatically?

Partly: per Shopify's Help Center, Theme Store themes get automatic bug and security fixes and other updates are manual; uploaded themes get none.

October 13, 2026

Orders & customers
Does Shopify have a request-a-quote option?

Shopify has no request-a-quote button we found; you build one with a draft order and invoice, B2B checkout to draft, or a form.

October 13, 2026

Stay updated

Get notified about new articles

Subscribe to receive updates when we publish new Shopify guides and insights.