Skip to content
Connect your store

Server-side tracking and profit bidding on a custom store (webhooks)

Built your own store? Your backend sends every order to Product Metrics as a signed webhook, and server-side conversions go to Google Ads, Meta and ChatGPT Ads, so you can bid on profit, new customers or lifetime value.

Custom Store / Webhook Integration is for a store you built yourself. Your backend sends every order to Product Metrics when it’s paid, refunded or cancelled, with its product costs and the customer’s order history. Product Metrics adds profit, new or returning customer and lifetime value, and sends it server-side to each ad channel you connect.

Your site also runs Cloudflare Tracking. Your backend knows the order, but not which ad click brought the customer or what they chose in your cookie banner: only the browser knows that. So the tracking on your pages links each visit to its order, and the order itself comes from your backend.

A custom store needs a developer: they connect your checkout and send orders from your backend. Everything else you do yourself, in Product Metrics and Cloudflare.

Prerequisites

  • A website whose domain uses Cloudflare DNS, with its DNS record proxied (the orange cloud).
  • A Cloudflare login for that account that can approve access. Product Metrics never changes your DNS.
  • A developer who can change your store’s checkout and backend.
  • A workspace on Pro: connecting a store is part of Pro. A workspace admin signs in to Cloudflare.

On Shopify, WooCommerce, Magento, Lightspeed or Shopware 6? Use that platform’s page: no developer work needed (Magento excepted).

Set it up with AI

Connect your assistant

First time? Add the Product Metrics MCP server to your assistant, then paste the prompt below.

In Claude, choose Add custom connector; in ChatGPT, Settings → Apps & Connectors. Paste this URL:

https://www.productmetrics.io/mcp

Claude Code: run this in your terminal.

claude mcp add --transport http product-metrics https://www.productmetrics.io/mcp

CodexAll clients and details →

Paste the prompt into your assistant.

Connect my custom store to Product Metrics with Custom Store / Webhook Integration. Check my setup status first, walk me through each open step, and give me the link when I need to sign in to Cloudflare.
Connect my custom store to Product Metrics with Custom Store / Webhook Integration. Check my setup status first, walk me through each open step, and give me the link when I need to sign in to Cloudflare.
Connect my custom store to Product Metrics with Custom Store / Webhook Integration, then help me send signed order webhooks from our backend and pass the order proof at checkout, following https://www.productmetrics.io/docs/platforms/custom-store. Use the Product Metrics MCP server, or the productmetrics CLI with --json and the Product Metrics skills if they are installed (run `productmetrics help agents` first).
Connect my custom store to Product Metrics with Custom Store / Webhook Integration, then help me send signed order webhooks from our backend and pass the order proof at checkout, following https://www.productmetrics.io/docs/platforms/custom-store. Use the Product Metrics MCP server, or the productmetrics CLI with --json and the Product Metrics skills if they are installed (run `productmetrics help agents` first).

In the app

1. Add your store

Go to Ecommerce platforms, select Connect on Custom Store / Webhook Integration and enter the domain your customers visit, for example www.example.com.

You should see the website under Cloudflare Tracking, with Custom Store chosen under Order source.

2. Send its orders to a property

Under Storefront scopes, link the property that should receive the orders.

3. Sign in to Cloudflare

In Tracking, under Complete your tracking setup, open Connect Cloudflare. A workspace admin:

  1. Selects Connect Cloudflare, signs in to Cloudflare and approves Product Metrics.
  2. Chooses the Cloudflare account and the Cloudflare zone your domain is in.
  3. Selects Set up gateway and keeps the page open until it finishes.

Product Metrics adds the tracking to every page of your domain. You should see Gateway setup complete.

4. Turn on order webhooks

Under Order source, keep Custom Store / Webhook Integration — send live order webhooks chosen and select Enable Custom Store. Copy the webhook endpoint and the signing secret and give them to your developer through your password manager.

The signing secret is shown once. From now on your backend’s orders count; purchases on your pages only link visits to orders.

You should see Current order source: Custom Store / Webhook Integration — live order webhooks and Webhook setup: Ready.

5. Your developer connects checkout and backend

Your developer follows For developers below, or the Developer quickstart: live orders under Order source. They:

  1. Save a tracking reference with each order at checkout, and report the same reference on the order confirmation page.
  2. Send each order from your backend when it’s paid, refunded or cancelled.
  3. Send a first order to the test webhook endpoint and select Check test delivery.

You should see Test webhook verified, with the event ID your developer sent.

6. Finish tracking setup

You should see the badge next to Tracking read Tracking active.

7. Check it works

Place a real order and pay for it. Under Order source, select Refresh order status.

You should see Webhook delivery: Order received with the time. More in Check tracking.

How it works on a custom store

On a custom store
InstallCloudflare sign-in for the tracking on your pages, plus webhooks from your backend
Order sourceYour backend’s webhooks. Purchases on your pages only link each visit to its order
Order sentEvery change: placed, paid, refunded or cancelled. Conversions count from payment
Product costThe cost price your backend records on each order line when the order is placed
New or returningFrom the order history your backend sends with each order
ConsentOneTrust, Cookiebot, Usercentrics or Osano, read on your pages
Refunds and cancellationsYour backend sends them; Product Metrics adjusts the conversion it sent
Earlier ordersNot imported: only orders paid after you turn on webhooks count
BillingPart of Pro

If the visit never arrives, Product Metrics waits up to an hour after payment, then keeps the order without it. Without the ad click and the visitor’s consent, that order may not reach your ad channels.

What you get on a custom store

FeatureChannelsOn this platform
Server-side conversion trackingGoogle Ads · Meta · ChatGPT AdsSent once your backend reports the order paid, linked to the visit on your pages.
Enhanced ConversionsGoogle Ads · Meta · ChatGPT AdsFrom the hashed email, phone and billing address your backend sends, only with ad user data consent.
Customer listsGoogle AdsCustomer Match lists from the orders your backend sends.
POAS and ROAS biddingGoogle Ads · Meta · ChatGPT AdsProduct costs from each order line, plus your additional costs.
New customer biddingGoogle Ads · MetaNew or returning from the order history your backend sends.
Returning customer biddingGoogle Ads · MetaOrders from customers who bought before, as their own conversion.
LTV biddingGoogle Ads · Meta · ChatGPT AdsObserved value from the paid orders your backend sends, not a prediction.

Troubleshooting

“Webhook setup isn’t finished”

Select Rotate signing secret to finish it, and give your developer the new secret.

“Couldn’t enable Custom Store”

If it says Connecting a store is part of Pro, start Pro, then select Enable Custom Store again.

“Awaiting first live order”

Your backend hasn’t sent a paid order yet, or Product Metrics rejected it. A rejected order returns its error to your backend: ask your developer to check it.

“No test webhook verified with the current signing secret”

After Rotate signing secret, earlier tests no longer count. Your developer sends a new test signed with the new secret.

Orders from before you turned on webhooks don’t appear

That’s expected: only orders paid after you selected Enable Custom Store count. There’s no import of earlier orders.

Fewer conversions than paid orders

Check that the confirmation page reports the same tracking reference your backend sends, and that consent names the banner your store shows.

“Proxy the storefront DNS record first”

Turn on the orange cloud for your domain’s DNS record in Cloudflare, then choose the zone again.

For developers

Send one complete order snapshot per change, as a POST to the webhook endpoint from step 4:

  • When: each time an order is placed, paid, refunded or cancelled. A new eventId (UUID) per change and a higher orderRevision per order; a retry sends the same saved body again.
  • Whole order, every time: all lines, totals and refunds so far, plus customerHistory: how many paid orders the customer had before this order’s payment. Work it out once, at payment, and send the same values on every later snapshot.
  • Cost on every line: unitCost, the cost price excluding tax when the order was placed. A missing cost is rejected; send 0 only for a known free item.
  • Money is a JSON integer in micros (12.34 is 12340000), excluding tax, in the order’s currency. Totals must add up exactly.
  • Customer (optional): SHA-256 hashes of the email, phone and billing name, plus plain country and postcode. Never send raw personal data.
  • Visit link: at checkout, create a random orderProof (32–128 letters, digits, _ or -), save it with the order, send it in tracking.orderProof, and pass the same string to sdk.purchase on the confirmation page.
{
  "schemaVersion": 1,
  "eventId": "019c0000-0000-7000-8000-000000000101",
  "orderRevision": 1,
  "occurredAt": "2026-10-21T10:01:00Z",
  "order": {
    "id": "order-1001",
    "transactionId": "ORDER-1001",
    "status": "paid",
    "createdAt": "2026-10-21T10:00:00Z",
    "paidAt": "2026-10-21T10:01:00Z",
    "currency": "EUR",
    "taxBasis": "exclusive",
    "customerId": "customer-42",
    "lines": [
      {
        "lineId": "line-1",
        "productId": "product-10",
        "variantId": "variant-10-blue",
        "quantity": 2,
        "currentQuantity": 2,
        "subtotalExTaxMicros": 100000000,
        "discountExTaxMicros": 10000000,
        "taxMicros": 18000000,
        "refunds": [],
        "unitCost": {
          "amountMicros": 20000000,
          "sourceReference": "order-1001:line-1:cost-at-sale",
          "observedAt": "2026-10-21T10:00:00Z"
        }
      }
    ],
    "totals": {
      "subtotalExTaxMicros": 100000000,
      "discountExTaxMicros": 10000000,
      "shippingExTaxMicros": 10000000,
      "shippingTaxMicros": 2000000,
      "taxMicros": 20000000,
      "totalMicros": 120000000,
      "refundedShippingExTaxMicros": 0,
      "refundedShippingTaxMicros": 0,
      "refundedTotalMicros": 0
    }
  },
  "customerHistory": {
    "priorQualifyingOrderCount": 0,
    "historyComplete": true,
    "evaluatedBefore": "2026-10-21T10:01:00Z"
  },
  "tracking": { "orderProof": "checkout_RandomOpaqueTokenWith32CharsMinimum" }
}

Sign the exact bytes you send: X-PM-Signature is the lowercase hex HMAC-SHA256 of timestamp + "." + body, keyed with the signing secret. The timestamp is Unix seconds and must be within five minutes; re-sign each retry.

import { createHmac } from "node:crypto";

const body = JSON.stringify(snapshot);
const timestamp = String(Math.floor(Date.now() / 1000));
const signature = createHmac("sha256", process.env.PM_SIGNING_SECRET)
  .update(`${timestamp}.${body}`)
  .digest("hex");

const response = await fetch(process.env.PM_WEBHOOK_URL, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-PM-Timestamp": timestamp,
    "X-PM-Signature": signature,
  },
  body,
});
ResponseWhat to do
202Accepted. Mark the event sent
200Already received, or older than a revision already received. Mark it sent
400Fix the field the response names; don’t resend unchanged
401Check the secret, the exact body and your clock
409An ID, revision or customer history changed, or the order was paid before webhooks were on
429, 5xx or no responseResend the same body later, with a fresh timestamp and signature

Keep the signing secret on your server. Rotate signing secret stops the old one at once.

FAQ

Do I need a developer for a custom store?

Yes. A developer connects your checkout and sends orders from your backend as signed webhooks. Everything else, including the Cloudflare sign-in, you do yourself.

Why does a custom store also need Cloudflare Tracking?

Your backend knows the order, but not which ad click brought the customer or what they chose in your cookie banner. The tracking on your pages links each visit to its order.

What happens when an order is refunded or cancelled?

Your backend sends the updated order, and Product Metrics adjusts the conversion it sent.

Where do product costs come from on a custom store?

From the cost price your backend sends on each order line, recorded when the order is placed. You add shipping, handling, returns and payment fees as additional costs.

Where next

Developers: add the website with the CLI or the API; turning on webhooks is done in the app.