Revenue Attribution
Stripe PaymentIntent API
Set up revenue attribution with Stripe Elements and PaymentIntent API. Pass DataFast cookies as metadata when creating or confirming PaymentIntents.
Make sure you've connected your Stripe account first.
When using Stripe Elements with the PaymentIntent API, pass metadata with faurya_visitor_id and faurya_session_id (cookies from Faurya) when creating a checkout session 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: {
faurya_visitor_id: cookieStore.get('faurya_visitor_id')?.value,
faurya_session_id: cookieStore.get('faurya_session_id')?.value
}
});
return new Response(JSON.stringify({ clientSecret: paymentIntent.client_secret }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}That's it! Once connected and metadata is properly passed, Faurya will automatically attribute revenue to the correct marketing channels via the payment_intent.succeeded webhook. No additional setup is required.
When to use this method
- Custom checkout flows using Stripe Elements with Stripe PaymentIntent API
- Mobile apps using Stripe's mobile SDKs
After receiving a successful payment, you should see revenue data in your dashboard (referrer, country, browser, etc.). If you don't, please contact us at team@faurya.com.