Klaviyo · Web Pixels API replacement · confidence: medium
Dies 2026-08-26
// Before using this template: check whether Klaviyo's official Shopify app
// is already installed — Klaviyo's native Shopify integration ships its own
// server-side order-webhook-based "Placed Order" event and does NOT depend
// on checkout.liquid at all. If that app is installed and active, this
// custom pixel would DOUBLE-fire "Placed Order" — do not install both.
// This template is for stores with a HAND-ROLLED learnq.push() and no
// Klaviyo app installed.
analytics.subscribe('checkout_completed', (event) => {
const { checkout } = event.data;
if (!checkout || !checkout.email) return; // Klaviyo profile identification requires an email
fetch('https://a.klaviyo.com/client/events/?company_id=KLAVIYO_PUBLIC_API_KEY', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
revision: '2024-10-15',
},
keepalive: true,
body: JSON.stringify({
data: {
type: 'event',
attributes: {
properties: {
OrderId: checkout.order ? checkout.order.id : checkout.token,
Total: checkout.totalPrice ? checkout.totalPrice.amount : undefined,
Items: checkout.lineItems.map((item) => ({
ProductName: item.title,
Quantity: item.quantity,
ItemPrice: item.variant ? item.variant.price.amount : undefined,
})),
},
metric: { data: { type: 'metric', attributes: { name: 'Placed Order' } } },
profile: { data: { type: 'profile', attributes: { email: checkout.email } } },
},
},
}),
});
});What this does NOT cover
What this does NOT cover: Klaviyo's Ordered Product, Refunded Order, or onsite behavioral events (product viewed, search) — each needs its own analytics.subscribe() call. It also does not detect whether Klaviyo's official Shopify app is already sending Placed Order server-side, which would make this snippet a duplicate-fire risk.
Klaviyo Signals migration · Legacy learnq.push + Additional Scripts loader + the new Signals Purchase replacement.