A common claim about Shopify Web Pixels: they are fine for analytics, but blind for ads, because they “can’t read cookies or click IDs”. Shopify’s own documentation says otherwise. A pixel can read first-party cookies and the page URL. What it can’t do is run before consent, touch the DOM, or carry a click ID from the landing page to the order on its own. The real limit is not access. It is orchestration.
What a Web Pixel can and cannot do
| Need | In a Web Pixel? | How (Shopify doc) |
|---|---|---|
Read _fbp, _fbc and other first-party cookies |
Yes | browser.cookie.get(name), an asynchronous method that runs in the top frame |
Read gclid, fbclid, UTM parameters |
Yes | event.context.document.location.search (or href) |
| Know the order, its value and currency | Yes | checkout_completed: data.checkout.order.id, totalPrice, currencyCode |
| Email and phone of the buyer | Yes, with scopes | data.checkout.email / phone (read_customer_email, read_customer_phone for app pixels) |
| Read or change the DOM | No | The pixel runs in a sandbox |
| Run without consent (EEA, UK) | No | “Web pixels run only when website visitors have provided the permissions required in the pixel configuration” |
Sources: Web Pixels API: browser, init (context, customer privacy), checkout_completed, custom pixel permissions.
So where does ad tracking break?
Three places, and none of them is “the pixel can’t see the IDs”:
- Consent. New custom pixels require Marketing and Analytics permissions by default. No consent, no pixel, no click ID. That is the intended behaviour, not a bug.
- Time. The click ID is in the URL of the landing page. The purchase happens later, sometimes several pages later. If nobody stores the ID, it is gone by the time
checkout_completedfires. - Destination. A pixel runs in the visitor’s browser. Anything in its code is public, so it must never hold a Conversions API token or a Google Ads credential. The pixel collects; a server sends.
Step 1: capture the click IDs on landing
In a custom pixel (Settings > Customer events), read the URL and the Meta cookies on page_viewed, and keep them for the rest of the visit:
analytics.subscribe("page_viewed", async (event) => {
const params = new URLSearchParams(event.context.document.location.search);
const gclid = params.get("gclid");
const fbclid = params.get("fbclid");
if (gclid || fbclid) {
// keep the click IDs until the order (use localStorage if buyers often switch tabs)
await browser.sessionStorage.setItem("click_ids", JSON.stringify({ gclid, fbclid }));
}
});
Step 2: send the order and the IDs to your server
analytics.subscribe("checkout_completed", async (event) => {
const checkout = event.data.checkout;
const ids = JSON.parse((await browser.sessionStorage.getItem("click_ids")) || "{}");
fetch("https://your-endpoint.example.com/conversions", {
method: "POST",
keepalive: true,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
event_id: event.id, // Shopify customer event ID
order_id: checkout.order?.id, // null on every event except checkout_completed
value: checkout.totalPrice?.amount,
currency: checkout.currencyCode,
email: checkout.email, // raw here, hashed on the server
fbp: await browser.cookie.get("_fbp"),
fbc: await browser.cookie.get("_fbc"),
gclid: ids.gclid || null,
fbclid: ids.fbclid || null
})
});
});
Step 3: let the server talk to the ad platforms
- Meta Conversions API. Send
fbpandfbcas they are (“Do not hash”). If_fbcis missing but you havefbclid, Meta documents the formatfb.${subdomain_index}.${creation_time}.${fbclid}. Hash the email (trimmed, lowercased, SHA-256) before sending it asem. Use the sameevent_idas the browser pixel so Meta can deduplicate. Meta: customer information parameters - Google Ads. Upload the conversion with the
gclidand the order ID through the Google Ads API. Google Ads API: conversions
Where an App Embed still helps
An app embed block is the theme extension that apps use for “analytics, or tracking pixels” with no visible UI. It is useful when you need a vendor SDK (fbq, gtag) to run on storefront pages. But Shopify is explicit: “Theme app extension app blocks and app embed blocks can’t be rendered on checkout pages.” So it can’t replace the pixel for the purchase, and it is not needed just to read cookies or click IDs. Shopify: theme app extension configuration
A clean architecture for ad tracking on Shopify
- Web Pixel: listens to Shopify events, captures click IDs and Meta cookies after consent, forwards the Shopify event ID, the order ID, the IDs and the value to your endpoint.
- Your server (server-side GTM or custom): hashes personal data, holds the tokens, calls Meta Conversions API and the Google Ads API.
- App Embed (optional): runs vendor SDKs on storefront pages when you need them.
Shopify’s sandbox did not remove the identifiers. It removed the shortcuts. You now have to capture, keep and forward them on purpose.
Related reading
- Shopify Web Pixels API: The New Era of E-commerce Tracking
- Shopify, GA4 & Custom Pixels: Taking Back Control of Your Tracking