The complete custom pixel for Shopify Web Pixels, commented and fronted by a CONFIG block, plus web and server containers as import-ready JSON. Built for stores that have to leave checkout.liquid before 26 August without losing attribution on the way out.
Why now
From 26 August 2026, checkout.liquid and the Additional Scripts field stop firing for Basic, Shopify and Advanced stores. Tracking that lives there stops working that day, with no error and no prompt. Web Pixels via customer events are the only supported route afterwards.
Moving is not enough on its own. The custom pixel runs in a sandbox, and three of its quirks cost data if you do not know about them.
What the template solves
- The iframe URL in GA4. In the sandbox,
document.locationreturns the iframe URL, not the shop's. The template readsevent.context.window.location. - A fresh client_id per purchase.
document.cookiethrows aSecurityErrorin the sandbox. Without access to_ga, every purchase gets a new identity and attribution falls apart. The template reads viabrowser.cookie.get(). - Lost add-to-carts. The app-generated pixel loads its code by
fetchand only subscribes after the network round trip. Anything before that is gone, and with an adblocker everything is. The template subscribes synchronously. - Duplicate purchases. The browser event and the server event are the same event. Without a shared
transaction_id, GA4 counts both. The template sets one order ID across every path. - Shop Pay and Express. Both lose the
client_idclient-side across the domain boundary. The template recovers it through cart attributes.
What you get
| File | Contents |
|---|---|
custom-pixel.js | The full script, commented, with a CONFIG block for measurement ID, server endpoint and consent groups |
web-container.json | Web GTM container, import-ready, triggers and variables included |
server-container.json | Server container with GA4 and Meta CAPI tags plus consent mapping |
qa-checklist.md | The steps that prove it counts |
How to run it
- Fill in the CONFIG block with your measurement ID and server endpoint.
- Add the script as a custom pixel under customer events in the Shopify admin.
- Import both containers, map the consent groups to your CMP.
- Place a test order in incognito.
purchasewith atransaction_idmust arrive exactly once. - After 48 hours, compare the GA4 order count against Shopify. The gap should be low single digits.
The full reasoning with every trap is in the companion article: Shopify server-side tracking with Stape.
Request the template
Enter your work email and the files arrive by mail. Soft gate, not a wall, the article stays fully readable.