Klaviyo integration

Forward BHmetrics events into Klaviyo so you can trigger flows on the same canonical signal BHmetrics uses for ad-platform CAPI dispatch. Two minutes of setup.

1. Create a Klaviyo private API key

  1. Klaviyo account → Settings → API Keys.
  2. Create a Private API Key with the Events: Write scope.
  3. Copy the key (starts with pk_).

2. Add an outbound webhook in BHmetrics

  1. Go to Settings → Outbound webhooks (Scale tier).
  2. Add subscription, URL: https://your-receiver.example.com/conduit-to-klaviyo.
  3. Subscribe to event.ingested.

3. Receiver: BHmetrics → Klaviyo

A 30-line proxy is all you need. Verify the HMAC signature, then call the Klaviyo Events API:

// Node receiver (Express / Vercel function)
import crypto from "node:crypto";

export default async function handler(req, res) {
  const expected = crypto
    .createHmac("sha256", process.env.CONDUIT_SECRET)
    .update(JSON.stringify(req.body))
    .digest("hex");
  if (req.headers["x-conduit-signature"] !== expected) return res.status(401).end();

  const { event, payload } = req.body;
  if (event !== "event.ingested") return res.status(200).end();

  await fetch("https://a.klaviyo.com/api/events/", {
    method: "POST",
    headers: {
      authorization: `Klaviyo-API-Key ${process.env.KLAVIYO_KEY}`,
      revision: "2024-10-15",
      "content-type": "application/json",
    },
    body: JSON.stringify({
      data: {
        type: "event",
        attributes: {
          properties: payload,
          metric: { data: { type: "metric", attributes: { name: "BHmetrics purchase" } } },
          profile: { data: { type: "profile", attributes: { _kx: payload.emailHash } } },
        },
      },
    }),
  });
  res.status(200).end();
}

4. Build a flow in Klaviyo

Use the new BHmetrics purchase metric as a flow trigger. Common patterns: post-purchase thank-you, repeat-customer reward, win-back at day 60.