Stripe revenue attribution
Tie paid customers back to the campaign that brought them in. Two steps, no webhook — Piqo polls your Stripe with the key you connect.
1. Connect Stripe in Piqo
In Settings → Stripe, paste a key (Stripe Dashboard → Developers → API keys). A restricted key with checkout.sessions:read + charges:read is enough — Piqo only reads, and there's no webhook to configure.
2. Pass the visitor id into checkout
On your checkout endpoint, read the piqo_visitor cookie and send it as metadata.piqo_visitor_id. The two marked lines are the only additions to your normal Checkout:
// app/api/checkout/route.js
import { cookies } from 'next/headers';
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
export async function POST(req) {
const visitorId = cookies().get('piqo_visitor')?.value; // ← required
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
line_items: [{ price: 'price_xxx', quantity: 1 }],
metadata: {
piqo_visitor_id: visitorId, // ← required
},
});
return Response.json({ url: session.url });
}What you'll see
Within a minute the payment lands on your Conversions page with the channel / country / UTM from the matching pageview, and its revenue shows on the chart. Payments without the metadata still count toward revenue totals — they just show as Direct.
Why a cookie? Stripe Checkout runs on a separate domain, so the visitor id has to travel as metadata. Cookie mode keeps the same id from first visit to purchase — even weeks later.