Attribute revenue with Stripe PaymentIntent API
Before proceeding, confirm that you have linked your Stripe account.
When using Stripe Elements with the PaymentIntent API, include metadata with _fs_vid and _fs_sid (cookies set by Flowsery Analytics) when creating a payment intent on your backend:
// app/api/create-payment-intent/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 paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: 'usd',
metadata: {
_fs_vid: cookieStore.get('_fs_vid')?.value,
_fs_sid: cookieStore.get('_fs_sid')?.value
}
});
return new Response(JSON.stringify({ clientSecret: paymentIntent.client_secret }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
That is all that is needed. Once connected and metadata is passed correctly, Flowsery Analytics will automatically attribute revenue to the appropriate marketing channels via the payment_intent.succeeded webhook. No additional configuration is required.
When to use this method
- Custom checkout flows using Stripe Elements with the Stripe PaymentIntent API
- Mobile apps using Stripe's mobile SDKs
Following a successful payment, revenue data should appear in your dashboard (referrer, country, browser, etc.).