Google Analytics (legacy UA) · Web Pixels API replacement · confidence: high
Dies 2026-08-26
// Universal Analytics stopped processing new hits in 2024 — this pattern is
// already fully dead, independent of the Aug 26 checkout change. There is no
// UA-shaped replacement; the correct fix is a full switch to GA4 Measurement
// Protocol, same as the ga4-gtag-purchase-checkout-liquid template. Shown
// here as its own entry because the detection signature (ga('ec:...')) is
// distinct and merchants searching for "enhanced ecommerce" still find this
// dead pattern in old themes.
analytics.subscribe('checkout_completed', (event) => {
const { checkout } = event.data;
if (!checkout || !checkout.totalPrice) return;
fetch(`https://www.google-analytics.com/mp/collect?measurement_id=MEASUREMENT_ID&api_secret=API_SECRET`, {
method: 'POST',
keepalive: true,
body: JSON.stringify({
client_id: event.clientId,
events: [{
name: 'purchase',
params: {
transaction_id: checkout.order ? checkout.order.id : checkout.token,
value: checkout.totalPrice.amount,
currency: checkout.totalPrice.currencyCode,
items: checkout.lineItems.map((item) => ({
item_id: item.variant && item.variant.id,
item_name: item.title,
quantity: item.quantity,
price: item.variant ? item.variant.price.amount : undefined,
})),
},
}],
}),
});
});What this does NOT cover
What this does NOT cover: historical UA data cannot be backfilled into GA4 — this snippet only fixes going-forward tracking.
Google Analytics / Ads / GTM family · GA4, Google Ads conversion, GTM dataLayer, and the legacy Universal Analytics enhanced-ecommerce path.