Configure Stripe Checkout tracking for back-attribution | Guides
Intermediate2 min

Configure Stripe Checkout tracking for back-attribution

Step-by-step guide to ensure your Stripe Checkout buttons forward client_reference_id to Metrikia, the prerequisite for back-attributing anonymous touchpoints.

Configure Stripe Checkout tracking for back-attribution

Why this matters

If you sell via Stripe Checkout (or Payment Links buy.stripe.com), your visitors pay before submitting a lead form. Without configuration, Metrikia cannot link the anonymous touchpoints (5 Meta ads viewed over 3 days for example) to the lead created at payment time.

The mechanism relies on the Stripe client_reference_id parameter. The Metrikia pixel auto-injects the visitor's mtk_vid into it. When Stripe completes the checkout, the server webhook reads this client_reference_id and back-attributes every anonymous touchpoint of the visitor to the newly created lead.

Prerequisites

  • Metrikia pixel v2.0+ deployed on all your public pages (back-attribution does not work on visitors who never saw the pixel).
  • Stripe webhook configured on the Metrikia side (Integrations settings).

If your checkout button is an <a> pointing to https://checkout.stripe.com/... or https://buy.stripe.com/..., you have nothing to do. The Metrikia pixel auto-detects these URLs and injects client_reference_id.

Verification:

  1. Open your payment page in a browser.
  2. Dev console (F12) โ†’ "Elements" tab.
  3. Inspect the payment button.
  4. You should see client_reference_id=<long-hex> in the href.

If the parameter does not appear, it means:

  • The pixel is not loaded on this page (check <script src="metrikia-pixel.js"> in the HTML).
  • The button is added dynamically after page load and the MutationObserver has not had time to tag it: manually call window.mtk('stripeify') after your render.

Method 2: Custom button with data-checkout

If you use an <a data-checkout> or a non-Stripe button that later redirects to Stripe via JavaScript, add the data-checkout attribute:

<a data-checkout href="https://your-app.com/start-checkout">Buy</a>

The pixel will inject client_reference_id on every link marked data-checkout.

If the Stripe redirect happens server-side, you must forward the mtk_vid to your backend and pass it as client_reference_id when creating the Stripe session:

// Read mtk_vid from the frontend
const mtkVid = window.mtk('getVisitorId');
fetch('/start-checkout', {
  method: 'POST',
  body: JSON.stringify({ mtkVid }),
});

// Backend (PHP example)
$session = \Stripe\Checkout\Session::create([
    'client_reference_id' => $request->mtkVid,
    // ... other params
]);

Verify back-attribution works

  1. Open your site in a private window (clean cookie).
  2. Navigate 2-3 pages.
  3. Click a test payment button.
  4. Complete checkout in Stripe test mode.
  5. Go to /app/leads โ†’ open the created lead โ†’ "Journey" tab.

You should see your 2-3 anonymous touchpoints linked to the lead, with a "back-attributed" mention.

Common issues

  • "client_reference_id appears in the URL but the webhook receives null": check your Stripe integration does not reset parameters. On Stripe Payment Links the parameter is preserved. On a server-created session, you must pass it explicitly.
  • "The visitor has an mtk_vid but no touchpoint appears before checkout": the pixel was probably not loaded on ad pages. Check the tag is deployed everywhere, not just on the payment page.
  • "I changed domains between the pixel and Stripe": this is normal, client_reference_id crosses the domain. The mtk_vid cookie stays on your site, client_reference_id travels as a query string to Stripe then returns in the webhook.

To go further, check out our blog, the documentation or contact support.

Ready to take action?

Create your Metrikia account and apply this guide in minutes.