Revenue attribution
Link payments to the traffic sources that generated them. attribu.tech tracks visitors from first click to purchase, so you know exactly which channels drive revenue.
How it works
- A visitor lands on your site. The pixel sets an
attribu_visitor_idcookie and records their source (UTMs, referrer, ad click IDs). - The visitor browses your site. Every pageview is tied to their visitor ID.
- The visitor clicks "Buy". Your checkout passes the
attribu_visitor_idandattribu_session_idcookies as Stripe metadata. - Stripe processes the payment and fires a webhook. attribu.tech saves the charge with the visitor ID from the metadata.
- The dashboard joins the charge to the visitor's first-touch event and shows which source drove the revenue.
Stripe Checkout API
When creating a Checkout Session on the server, pass the attribu.tech cookies as metadata. Here is an example using Next.js App Router:
// app/api/checkout/route.ts
import { cookies } from "next/headers";
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
export async function POST(req: Request) {
const cookieStore = await cookies();
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: cookieStore.get("attribu_visitor_id")?.value || "",
attribu_session_id: cookieStore.get("attribu_session_id")?.value || "",
},
});
return Response.json({ url: session.url });
}metadata field must be on the Checkout Session itself, not on the line item or product. attribu.tech reads session-level metadata from the webhook.Stripe PaymentIntent API
If you create PaymentIntents directly instead of using Checkout Sessions, pass the cookies the same way:
// app/api/payment/route.ts
import { cookies } from "next/headers";
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
export async function POST(req: Request) {
const { amount } = await req.json();
const cookieStore = await cookies();
const paymentIntent = await stripe.paymentIntents.create({
amount,
currency: "usd",
metadata: {
attribu_visitor_id: cookieStore.get("attribu_visitor_id")?.value || "",
attribu_session_id: cookieStore.get("attribu_session_id")?.value || "",
},
});
return Response.json({ clientSecret: paymentIntent.client_secret });
}Stripe Payment Links
If you use Stripe Payment Links, no extra code is needed. The attribu.tech pixel automatically detects the ?session_id=cs_xxx parameter on your success page and sends a payment event to your dashboard.
Just make sure your Payment Link redirects to a success page on your domain where the pixel is installed. Stripe appends ?session_id=cs_xxx to the URL automatically.
What you'll see
Once payments are flowing, your attribu.tech dashboard shows revenue broken down by:
- Source - Google, Facebook, Twitter, newsletter, direct, etc.
- Campaign - Which ad campaign or UTM campaign drove the sale
- Channel - Paid Search, Organic Social, Email, Referral, etc.
- Country - Where the paying customer is located
- Landing page - Which page the customer first visited
You can see total revenue, number of paying customers, and average order value for each dimension.
What's next
- Connect Stripe - Set up your API key and webhooks.
- Shopify integration - Revenue attribution is handled automatically for Shopify stores.
- Attribution model - Learn how first-touch attribution works.