Skip to content
Cart
SHOPIFY DEVELOPMENT

Shopify Web Pixels API: What It Can and Can't Do for Tracking

Web pixels are the supported way to track on Shopify, but they run in a sandbox that can listen to events and nothing else, which changes how you build, debug and trust your tracking.

JA
Jatin Sangani October 2026 11 min read SHOPIFY DEVELOPMENT
In this article:

    The short version

    • A web pixel is JavaScript that subscribes to Shopify's customer events and sends them somewhere. It is the supported way to track on Shopify, and it replaces script tags for analytics.
    • App pixels (shipped inside an app) run in a strict sandbox. Custom pixels (pasted into Settings > Customer events) run in a looser iframe sandbox. Both can listen to events, and neither can read or change your page.
    • Consent is built in. In regions that require consent, your callbacks only run after the visitor agrees, and earlier events are replayed.
    • Three gaps to plan for: no DOM access, no client-side pixels in AI-channel direct checkout, and an API Shopify doesn't version.

    Last verified against Shopify's developer documentation on October 19, 2026.

    Since October 1, apps can no longer create new script tags, and Shopify stops loading the existing ones on March 1, 2027. For tracking, the replacement is the Shopify Web Pixels API. It is better than script tags for privacy and performance, but it works differently enough that a straight port of an old tracking snippet will fail.

    This guide covers how web pixels work, what they can do, what they can't, how to build and activate one, and when to reach for something else. It is written for developers and for the technical marketers who inherit the results.

    What is the Shopify Web Pixels API, and how does it work?

    Shopify Web Pixels API: a controlled set of APIs that lets a pixel subscribe to the customer events Shopify publishes, such as page views, add-to-carts and completed checkouts, from inside a sandbox on the visitor's browser.

    As a customer browses the online store, they trigger customer events that Shopify publishes to a data layer, or event bus. Your pixel subscribes to those events, reshapes each payload to match your data collection endpoint, and sends it on. Shopify says pixels can securely reach all surfaces, including the storefront, checkout and post-purchase pages, without the merchant pasting tracking code.

    There are two kinds of pixel, and the difference decides what you can build:

    App pixel Custom pixel
    Where it lives A web pixel extension shipped inside an app Code a merchant pastes into Settings > Customer events
    Sandbox Strict: a web worker Lax: an iframe with the allow-scripts and allow-forms sandbox values
    Merchant-editable settings Yes, through the settings object No settings property
    Best for An app serving many stores One store, or a legacy JavaScript pixel

    Shopify's own guidance is to build an app and have merchants install it instead of relying on custom pixels, because an app gives you a cleaner integration and a version you control. Custom pixels are the right call for a single store with a one-off tag.

    What can a Shopify web pixel do?

    A pixel gets a small, deliberate toolbox called the Standard API. For app pixels it has four parts:

    • analytics: subscribe to Shopify's customer events, and publish your own.
    • browser: asynchronous access to cookies, localStorage and sessionStorage, which run in the top frame on your behalf.
    • init: a snapshot of the page at render time, including its context and the cart and customer data.
    • settings: the merchant's configuration, set through the GraphQL Admin API (app pixels only).

    The events you subscribe to are standard events, grouped here by where they fire in the funnel:

    Stage Standard events
    Browse page_viewed, collection_viewed, product_viewed, search_submitted
    Cart product_added_to_cart, product_removed_from_cart, cart_viewed
    Checkout checkout_started, checkout_contact_info_submitted, checkout_address_info_submitted, checkout_shipping_info_submitted, payment_info_submitted, checkout_completed
    Diagnostics alert_displayed, ui_extension_errored

    You can subscribe to several events at once with all_events, all_standard_events, all_custom_events or all_dom_events. Treat those groups with care, because Shopify says their contents change as events are added or modified. Subscribe to named events in production.

    You can also publish custom events from your theme, for example Shopify.analytics.publish("special_email_signup", { email_campaign_id: 123 }), and subscribe to them the same way as standard events. Here is a complete app pixel that sends completed orders to your own endpoint and keeps consent state current:

    import { register } from "@shopify/web-pixels-extension";
    
    register(({ analytics, init, settings, customerPrivacy }) => {
      // Start from the consent state at page render, then keep it current.
      let consent = init.customerPrivacy;
      customerPrivacy.subscribe("visitorConsentCollected", (event) => {
        consent = event.customerPrivacy;
      });
    
      analytics.subscribe("checkout_completed", async (event) => {
        const checkout = event.data.checkout;
        await fetch(`https://collect.example.com/v1/${settings.accountID}`, {
          method: "POST",
          keepalive: true,
          body: JSON.stringify({
            eventId: event.id,
            name: event.name,
            orderId: checkout.order?.id,
            total: checkout.totalPrice?.amount,
            currency: checkout.currencyCode,
            consent,
          }),
        });
      });
    });

    Your endpoint must support CORS, because the pixel's fetch behaves like any cross-origin browser request.

    What can't a Shopify web pixel do?

    This is the section most teams find out about the hard way. Each limit below comes from how the sandbox is built, and each has a workaround.

    Limit What it means What to do instead
    No DOM access A pixel can't scrape the page or write to it. Code that touches window.document fails in the strict sandbox. Use the data in init and the event payloads. For anything that draws on the page, use an app embed block.
    Almost no browser globals Shopify only guarantees self, console, the timer functions and fetch with its related classes. Others can be removed at any time. Use the browser API for cookies and storage. Don't depend on any other global.
    Consent can delay or block events Where consent is required, callbacks run only after the visitor agrees. Earlier events are then replayed. Where tracking is on by default, callbacks run until the visitor opts out. Design for late delivery. Read consent status from init.customerPrivacy and the visitorConsentCollected event.
    You can't call the Customer Privacy API Pixels honor the visitor's consent signals but can't call that API directly. Use the pixel's own consent signals described above.
    CORS applies to your endpoint Requests from the pixel must come from a CORS-enabled server. Allow the pixel's origin on your collection endpoint.
    Custom pixels can't see the top frame Values like the page URL come from the sandbox iframe, not the real page. Read page context from the event's context data instead of window.
    No client-side pixels in AI-channel direct checkout In Microsoft Copilot and Google AI Mode direct checkout, Google Analytics and custom client-side pixels don't fire. Only server-to-server started and completed pixels do. Use channel attribution on orders in your admin and server-side tracking. See our Shopify agentic commerce guide.
    The API isn't versioned Shopify lists the Web Pixels API as unversioned, so it can change at any time. Watch the developer changelog, and keep your pixel logic thin.

    Two more are worth saying plainly. Pixels run in the visitor's browser, so anything that interrupts the browser (a blocked request, a closed tab mid-send) can drop an event. And on a headless storefront, a pixel only sees events that get published to Shopify's event bus, so your storefront code has to publish them. Check how your framework handles customer events before you rely on a pixel there.

    Shopify also asks that pixels not log content to the console in production. Remove your debug output before you deploy.

    Consent is part of the design, not an add-on. Pixels honor the consent signals the visitor chose, and you read them in two ways:

    • At page render: init.customerPrivacy holds the starting status.
    • When it changes: subscribe to visitorConsentCollected and update your local copy. The status object tells you whether analytics processing, marketing, preferences processing and sale of data are allowed.

    For an app pixel, you also declare in shopify.extension.toml that the pixel requires analytics permission (customer_privacy with analytics = true). New custom pixels require both Marketing and Analytics permissions by default, which is why a custom pixel can stay quiet for visitors who accepted only one.

    The practical rule: include the consent status in what you send, and let your backend decide what to do with it. That keeps you correct if a regulation or a visitor's choice changes.

    How do you build and activate a Shopify app web pixel?

    1. Scaffold the extension. From your app, run shopify app generate extension and choose the web pixel template.
    2. Configure it. The extension's shopify.extension.toml sets the name, the sandbox and the privacy declaration, plus any merchant-facing settings:
      name = "my-tracking-pixel"
      type = "web_pixel_extension"
      runtime_context = "strict"
      
      [customer_privacy]
      analytics = true
      
      [settings]
      type = "object"
      
        [settings.fields.accountID]
        name = "Account ID"
        description = "The account events are sent to"
        type = "single_line_text_field"
    3. Subscribe to events. Write the register function as in the example above.
    4. Add the access scope. Request read_customer_events in shopify.app.toml.
    5. Deploy. Run shopify app deploy. The pixel appears in the store's App pixels list with a Disconnected status.
    6. Activate it per store. Run the webPixelCreate mutation on each store, passing the merchant's settings. Until that runs, the pixel isn't created or configured, and it isn't subscribed to any customer events.

    Step 6 is the one that burns afternoons. A deployed extension that shows Disconnected is working as designed. It is waiting for a web pixel record. Build the mutation into your app's install or onboarding flow so merchants never see that state.

    Test on a development store and trigger a real checkout end to end, because events from the checkout fire only once you reach those steps. One timing note: tracking changes made inside the Black Friday freeze, November 16 through Cyber Monday on November 30, are the ones most likely to be wrong and noticed last. Ship pixel changes before November 13, or wait until December 2.

    When should you use a web pixel, and when something else?

    What you need Use Why
    Listen to storefront and checkout events and send them to GA4, Meta, TikTok or your own endpoint Web pixel It is the supported route, it respects consent, and it needs no merchant action
    Draw UI, change the page, or read the DOM App embed block or app block Pixels can't touch the page. See Shopify app embed blocks vs app blocks
    A reliable purchase signal that browser problems can't drop A server-side event as well Send the order from an order webhook or Event, and de-duplicate against the pixel using a shared ID. See our Shopify API 2026-10 upgrade checklist for Events
    Replace a legacy tracking script tag Web pixel for analytics only It is the supported replacement. See our script tag migration guide
    Tracking on a one-off store without an app Custom pixel Fastest path, with the lax sandbox limits above

    If you are evaluating vendors, ask whether their tracking ships as a web pixel, and whether it also sends a server-side purchase event. If you need ad platform tracking audited or rebuilt, our marketing app integrations team does that work. Custom app builds that include a pixel sit with bespoke app development. And if you are weighing who should own this, our guide on how to choose a Shopify development agency lists the questions to ask.

    Common questions about the Shopify Web Pixels API

    What is the difference between an app pixel and a custom pixel in Shopify?

    An app pixel is a web pixel extension shipped inside an app and runs in a strict sandbox. A custom pixel is code a merchant pastes into Settings > Customer events and runs in a lax iframe sandbox. App pixels get a settings object for merchant configuration, while custom pixels don't, and Shopify recommends apps over custom pixels where possible.

    Can a Shopify web pixel access the DOM or change my page?

    No. App pixels run in a web worker with only a few guaranteed globals, so they can't read or write the DOM. Custom pixels run in a sandboxed iframe that can't reach the top frame. To draw anything on the page, use an app embed block instead.

    Why isn't my Shopify web pixel firing?

    The usual causes are that no web pixel record exists yet (the extension shows Disconnected until the webPixelCreate mutation runs), the visitor hasn't given the consent your pixel requires, or the event isn't one you subscribed to. Orders placed in Copilot or Google AI Mode direct checkout also don't fire client-side pixels. Check the Customer events page, then test a full checkout on a development store.

    Do Shopify web pixels respect customer consent?

    Yes. In regions that require consent, pixel callbacks run only after the visitor agrees, and earlier events are replayed. In regions where tracking is on by default, callbacks run until the visitor opts out. Your pixel can read the current status from init.customerPrivacy and update it through the visitorConsentCollected event.

    Are web pixels replacing script tags for tracking on Shopify?

    Yes, for analytics and conversion data. Apps can no longer create or update script tags as of October 1, 2026, and Shopify stops injecting them into storefronts on March 1, 2027. A script that only collects data should move to a web pixel, and anything that draws on the page should move to an app embed block.

    Can an agency migrate our Shopify tracking to web pixels?

    Yes. BrainBox Infoway provides Shopify development and AI automation for ecommerce from Ahmedabad, India, with ~20 specialists serving merchants and agencies in the US, EU, AUS, and CAN. The team audits your current tags, rebuilds them as web pixels, and adds server-side purchase events where accuracy matters. Agencies can hand the work over under a white-label arrangement, or you can get a free quote for your store.

    Is your Shopify tracking still on script tags?

    We audit your tags, rebuild them as web pixels, and add server-side purchase events where accuracy matters.

    Get a Free Quote
    JA

    Jatin Sangani

    Founder, BrainBox Infoway

    Jatin has worked on Shopify projects since 2014 - first as a freelance developer, then as co-founder of a prior agency, and since 2023 as founder of BrainBox Infoway. He leads a team of ~20 Shopify specialists serving merchants and agencies in the US, EU, AUS, and CAN markets.

    View all articles by Jatin

    Keep Reading

    More from the Shopify Development cluster

    Your store isn't going to fix itself.

    Tell us what you're building or solving. We'll scope it honestly and respond within 24 hours.