Attribute revenue with Stripe Checkout API
Before proceeding, confirm that you have linked your Stripe account.
Include metadata with _fs_vid and _fs_sid (cookies set by Flowsery Analytics) when creating a checkout session:
// app/api/create-checkout/route.js
import { cookies } from 'next/headers';
export async function POST() {
const cookieStore = cookies();
// If you're using Next.js 15+, use this instead:
// const cookieStore = await cookies();
const session = await stripe.checkout.sessions.create({
line_items: [...],
mode: 'payment',
metadata: {
_fs_vid: cookieStore.get('_fs_vid')?.value,
_fs_sid: cookieStore.get('_fs_sid')?.value
}
});
return new Response(JSON.stringify({ sessionId: session.id }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
Once connected and metadata is passed correctly, Flowsery Analytics will automatically attribute revenue to the appropriate marketing channels. No webhook configuration is needed.
Following a successful payment, revenue data should appear in your dashboard (referrer, country, browser, etc.).