Google Ads · Web Pixels API replacement · confidence: medium
Dies 2026-08-26
analytics.subscribe('checkout_completed', (event) => {
const { checkout } = event.data;
if (!checkout || !checkout.totalPrice) return;
// Google Ads conversion tracking has no client-side sandbox equivalent to
// gtag('event','conversion', {send_to: 'AW-XXX/YYY'}) — the sandbox-correct
// path is the Google Ads Enhanced Conversions for Leads / Click Conversion
// Upload API (server-side), OR routing through GA4 (previous snippet) with
// a linked Google Ads account importing the GA4 "purchase" conversion.
// If a direct Ads-only conversion action must stay separate from GA4,
// forward it here via the same Measurement Protocol call used for GA4 —
// Google Ads reads GA4-linked conversions automatically once the accounts
// are linked in Google Ads > Conversions > Import.
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,
},
}],
}),
});
});What this does NOT cover
What this does NOT cover: legacy `send_to: 'AW-XXXXXXX/YYYYYYYYY'` conversion-action-specific gtag calls with NO GA4 involvement at all require the separate Google Ads API Click Conversion Upload (server-side, OAuth) — flagged here as ambiguous, needs case-by-case setup per store.
Google Analytics / Ads / GTM family · GA4, Google Ads conversion, GTM dataLayer, and the legacy Universal Analytics enhanced-ecommerce path.