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.
rk_live_...), not your secret key. The key only needs read access to Charges, Checkout Sessions, and Customers.Creating a restricted key
- Go to Stripe Dashboard > API Keys
- Click "Create restricted key"
- Name it "attribu.tech" or similar
- Set these permissions:
- Charges: Read
- Checkout Sessions: Read
- Customers: Read
- 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
- Visitor lands on your site, pixel sets
attribu_visitor_idcookie - Pixel records the pageview with UTMs, referrer, and device info
- Visitor clicks "Buy", your checkout passes the cookie as metadata
- Stripe webhook fires, attribu.tech saves the charge with the visitor ID
- Dashboard joins charges to events via visitor ID, reads the first-touch source
Webhooks
attribu.tech automatically configures a Stripe webhook when you connect your API key. It listens for:
charge.succeeded- records every successful paymentcheckout.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
- Install the pixel on your site
- Visit your site to generate a pageview
- Make a test purchase (use Stripe test mode)
- Check your attribu.tech dashboard - the charge should appear with the traffic source