We’re upgrading our email infrastructure — for immediate response, email andrewjgaber@gmail.com meanwhile.
Skip to main content
Part of Digital Empire
Affiliate / Other

Klaviyo learnq.push(['track', 'Placed Order'])

Klaviyo · Web Pixels API replacement · confidence: medium

Dies 2026-08-26

Paste-ready snippet
// 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 } } },
        },
      },
    }),
  });
});

Legacy pattern detected via: _?learnq\.push\(\s*\[\s*['"]track['"]\s*,\s*['"]Placed Order['"]

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.

Test-event verification checklist

  • checkout.email requires the read_customer_email access scope per Shopify docs (Protected Customer Data) — confirm the storefront/pixel context has this before relying on it; falls back to skipping the send if null rather than sending a profile-less event.
  • Klaviyo's official Shopify app is NOT also installed and firing its own server-side Placed Order event for the same order (duplicate-event check, verify in Klaviyo Metrics > Placed Order that each order appears once).
  • OrderId uses checkout.order.id (populated only on checkout_completed) so it matches the Shopify order number Klaviyo flow filters typically key off. Fires once per completed order, on the Thank You page.
  • Verify live against the platform's own test-event tool: https://developers.klaviyo.com/en/reference/create_client_event

Related paste-ready snippets

Klaviyo Signals migration · Legacy learnq.push + Additional Scripts loader + the new Signals Purchase replacement.