Stripe integration

attribu.tech connects to Stripe to attribute every payment to the traffic source that brought the customer. There are two parts: connecting the API key and passing visitor metadata through checkout.

1. Connect your Stripe key

Go to Settings > Revenue in your attribu.tech dashboard and paste your Stripe restricted API key.

Use a restricted key (rk_live_...), not your secret key. The key only needs read access to Charges, Checkout Sessions, and Customers.

Creating a restricted key

  1. Go to Stripe Dashboard > API Keys
  2. Click "Create restricted key"
  3. Name it "attribu.tech" or similar
  4. Set these permissions:
    • Charges: Read
    • Checkout Sessions: Read
    • Customers: Read
  5. Copy the key and paste it in attribu.tech settings

2. Pass visitor ID to checkout

The key to attribution is passing the attribu.tech cookies through your Stripe checkout session as metadata. When the payment succeeds, attribu.tech reads the metadata to link the charge to the visitor.

Stripe Checkout (server-side)

// Node.js / Next.js API route
const session = await stripe.checkout.sessions.create({
  mode: "payment", // or "subscription"
  line_items: [{ price: "price_xxx", quantity: 1 }],
  success_url: "https://yourdomain.com/success?session_id={CHECKOUT_SESSION_ID}",
  cancel_url: "https://yourdomain.com/",
  metadata: {
    attribu_visitor_id: req.cookies.attribu_visitor_id || "",
    attribu_session_id: req.cookies.attribu_session_id || "",
  },
});

Stripe Payment Links

If you use Stripe Payment Links, the pixel automatically detects the ?session_id=cs_xxx parameter on your success page and sends it to attribu.tech. No code changes needed.

Client-side Stripe.js

If you create checkout sessions from the client, read the cookies and send them to your server:

// Client-side
function getCookie(name) {
  const match = document.cookie.match(
    new RegExp("(^| )" + name + "=([^;]+)")
  );
  return match ? match[2] : "";
}

const res = await fetch("/api/create-checkout", {
  method: "POST",
  body: JSON.stringify({
    priceId: "price_xxx",
    attribu_visitor_id: getCookie("attribu_visitor_id"),
    attribu_session_id: getCookie("attribu_session_id"),
  }),
});

How attribution works

  1. Visitor lands on your site, pixel sets attribu_visitor_id cookie
  2. Pixel records the pageview with UTMs, referrer, and device info
  3. Visitor clicks "Buy", your checkout passes the cookie as metadata
  4. Stripe webhook fires, attribu.tech saves the charge with the visitor ID
  5. Dashboard joins charges to events via visitor ID, reads the first-touch source
That's it. The visitor ID cookie traveling through Stripe metadata IS the attribution link. No email matching, no identity resolution needed.

Webhooks

attribu.tech automatically configures a Stripe webhook when you connect your API key. It listens for:

  • charge.succeeded - records every successful payment
  • checkout.session.completed - captures metadata from checkout

The webhook endpoint is https://attribu.tech/api/webhooks/stripe. You don't need to configure this manually.

Testing

  1. Install the pixel on your site
  2. Visit your site to generate a pageview
  3. Make a test purchase (use Stripe test mode)
  4. Check your attribu.tech dashboard - the charge should appear with the traffic source
Copied