On this page
What this issue is
In Shopify, Settings > Customer events lets you add custom pixels and app pixels. Shopify runs them in a sandbox: an isolated iframe (a page inside a page) with limited access. This keeps checkout safe and fast.
The catch is that your pixel cannot see the storefront. It cannot use document.querySelector on the shop page, read window.dataLayer from the theme, or rely on theme scripts. It only receives events Shopify sends, such as page_viewed, product_added_to_cart and checkout_completed. If your code expects more, events go missing or hits never leave the sandbox.
Why it costs you leads or sales
Customer Events is where purchase tracking lives on checkout extensibility stores. If the pixel fails, GA4, Google Ads, Meta or TikTok get no purchase. Ad platforms then optimise on thin data, reports undercount revenue, and you may cut campaigns that actually work.
- Ad clickVisitor lands on the store
- CheckoutOrder is paid
- Sandbox pixelCode reads the DOM or a global that does not exist
- Ad platform hitNo purchase sent
- ReportingRevenue and ROAS undercounted
The checkout works for the customer, but the pixel fails inside the sandbox, so the ad platforms never hear about the sale.
Example: 100 real orders in a week, but a broken sandbox pixel reports only some of them to the ad platform.
How to check if your site has it
- Purchases in Shopify are higher than purchases in GA4, Meta or Google Ads
- The pixel is in Settings > Customer events but its status is not Connected
- Your pixel code uses document, window.dataLayer, jQuery or theme variables
- Browser console shows errors from the pixel iframe
- Events appear on product pages but not at checkout, or the reverse
- You still have an old theme snippet or checkout.liquid tracking next to the pixel
Open Customer eventsShopify
In Shopify admin go to Settings > Customer events and open your custom pixel. Confirm it is Connected, not just saved.
Use the pixel helper
Browse the store with the Meta Pixel Helper, Google Tag Assistant or the browser Network tab open. Filter for the platform domain, for example google-analytics.com or facebook.com/tr.
Look inside the sandbox
Hits come from a sandbox iframe, not the main page. In the Network tab, check requests from the sandbox frame and look for errors in the console.
Place a test orderShopify
Use Shopify's test mode or a Bogus Gateway on a development store. Confirm checkout_completed sends one hit with value and currency.
How to fix it
Rewrite the pixel so it only uses what the sandbox provides: the analytics and browser objects, and the data in each event.
analytics.subscribe('checkout_completed', (event) => {
const checkout = event.data.checkout;
const payload = {
event: 'purchase',
transaction_id: checkout.order ? checkout.order.id : checkout.token,
value: checkout.totalPrice.amount,
currency: checkout.currencyCode
};
fetch('https://YOUR-ENDPOINT.example/collect', {
method: 'POST',
keepalive: true,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
});Remove DOM and global code
In Settings > Customer events, edit the pixel. Delete anything that uses document, window.dataLayer or theme variables.
Use analytics.subscribe
Subscribe to standard events such as page_viewed, product_viewed, product_added_to_cart, checkout_started and checkout_completed, and read values from event.data.
Read cookies with the browser object
Use await browser.cookie.get('name') instead of document.cookie, and browser.localStorage or browser.sessionStorage for storage.
Set customer privacy
Under Customer privacy on the pixel, choose the right permission (for example Marketing or Analytics) so the pixel is not blocked for visitors who consented.
Save and Connect
Click Save, then Connect. Check the status shows Connected.
Do not paste the normal container
A standard GTM snippet that relies on page DOM triggers will not work in the sandbox. Use a version of the container designed for Shopify's web pixel, or push events to a server endpoint.
Map Shopify events to dataLayer
In the pixel, push a dataLayer object for each subscribed event, then trigger tags on Custom Event names rather than click or DOM triggers.
Avoid duplicates
Remove any theme-level GTM purchase tag so one order is not counted twice.
Use the Web Pixels API
If you build an app pixel, register it with the Web Pixels extension and use the same analytics.subscribe pattern.
Send hits from the sandbox
Use fetch or navigator.sendBeacon to your own endpoint or the platform's collect URL. Include the platform's required IDs.
How to confirm it's fixed
- The pixel status in Customer events is Connected
- A test order sends exactly one purchase hit with value, currency and an order ID
- The hit shows in GA4 DebugView, Meta Events Manager Test Events or the platform's own debug tool
- Add to cart and checkout started also appear
- Counts in the ad platform match Shopify orders over a few days, allowing for consent and ad blockers
How to prevent it happening again
Keep one owner for tracking. Document which events each pixel sends. Test after theme changes, app installs, checkout customisation and any edit to Customer events. Compare ad platform conversions with Shopify orders weekly, and investigate when the gap changes.
How FunnelGuard handles this
FunnelGuard detects this issue only partly. It runs your real customer journey on a schedule, and it captures the hits sent from the sandbox iframe, so it can see when expected tracking hits to GA4, Google Ads, Meta, TikTok and other platforms are missing from a run. When a failure repeats from a second region, you get one alert with a screenshot and a likely cause.
What it does not do: it does not read your pixel code, tell you which line of sandbox JavaScript is wrong, or check every event type at every step. It also stops before payment unless your store's test mode is set up, so the real purchase event is only covered if you configure test mode.
To cover the rest by hand: open Settings > Customer events and confirm the pixel is Connected, place a test order in test mode, check the platform's debug tool, and compare ad platform conversions with Shopify orders each week. You can start with the Free plan (1 site, 2 journeys, daily checks, no card) or run a free read-only website audit.
Questions people ask
Why is my Shopify custom pixel not firing?
Most often the code was written for a normal web page. Shopify runs custom pixels in a sandboxed iframe, so code that uses document, window.dataLayer or theme scripts fails. Rewrite it with analytics.subscribe and read data from event.data. Also check the pixel status is Connected.
Why is Shopify checkout_completed not sending a purchase event?
Common causes are a pixel that is saved but not connected, code that errors inside the sandbox, a customer privacy setting that blocks the pixel, or a missing endpoint ID. Check the console for errors and place a test order to see whether a hit leaves the sandbox.
What is the Shopify Customer Events sandbox?
It is an isolated iframe where custom and app pixels run. It limits access to the storefront and checkout for security and speed. Pixels get events through analytics.subscribe and use the browser object for cookies and storage.
Can I use Google Tag Manager in Shopify Customer Events?
You can, but a standard container that relies on page DOM triggers will not behave the same in the sandbox. Push Shopify events into a dataLayer inside the pixel and trigger tags on custom events, or send the data to a server endpoint.
How do I debug a Shopify custom pixel?
Open the store with the browser Network tab and console, then use the platform's debug tool such as GA4 DebugView or Meta Test Events. Look for requests from the sandbox frame and any errors. A test order checks the checkout events.
Why do my Shopify orders not match GA4 or Meta purchases?
Some gap is normal because of consent choices and ad blockers. A large or growing gap points to a broken pixel, double firing, or an old script still running. Compare over several days and test an order.
Can FunnelGuard check my Shopify Customer Events pixel?
Partly. It captures hits sent from the sandbox iframe during a scheduled journey, so it can flag missing tracking. It does not inspect your pixel code or cover the real purchase unless test mode is set up.
Related issues
- TRK-393Shopify checkout extensibility removed checkout.liquid scriptsFix guide
- TRK-395Shopify thank-you 'additional scripts' deprecated, purchase lostFix guide
- TRK-392Headless checkout loses tracking from main siteFix guide
- TRK-401Iframe-embedded checkout tracking not reaching parentFix guide
- TRK-389SPA route change sends no page_viewFix guide
- TRK-390SPA sends page_view twice per routeFix guide