Meta / Facebook · Web Pixels API replacement · confidence: high
Dies 2026-08-26
// Web Pixels API replacement — subscribe to checkout_completed, which fires
// once per checkout (Thank You page), per Shopify's own docs.
analytics.subscribe('checkout_completed', (event) => {
const { checkout } = event.data;
if (!checkout || !checkout.totalPrice) return;
const value = checkout.totalPrice.amount;
const currency = checkout.totalPrice.currencyCode;
const contentIds = checkout.lineItems
.map((item) => item.variant && item.variant.id)
.filter(Boolean);
// Meta's fbq() global does not exist inside the Web Pixels sandbox (no DOM,
// no window.fbq). Send the event to Meta's Conversions API endpoint via
// fetch instead — this is the sandbox-correct equivalent of a browser-side
// fbq('track','Purchase') call. Replace PIXEL_ID and ACCESS_TOKEN with your
// Meta Pixel ID and a server-side Conversions API access token (Events
// Manager > Settings > Conversions API).
fetch(`https://graph.facebook.com/v20.0/PIXEL_ID/events?access_token=ACCESS_TOKEN`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
keepalive: true,
body: JSON.stringify({
data: [{
event_name: 'Purchase',
event_time: Math.floor(Date.now() / 1000),
event_id: checkout.token, // dedup key shared with any server-side CAPI call
action_source: 'website',
custom_data: {
value,
currency,
content_ids: contentIds,
content_type: 'product',
},
}],
}),
});
});What this does NOT cover
What this does NOT cover: the server-side Conversions API purchase call, which is a separate integration merchants must verify independently for event_id dedup against this browser-side fire. It also does not cover Meta events earlier in the funnel (AddToCart, InitiateCheckout) — those need their own templates.
Meta / Facebook family · Meta Pixel + Meta CAPI + Meta Ads post-purchase — Aug 26 breakage is same across all.