Best analytics tool I've used in 14 years

Revenue attribution guide

Attribute revenue with Stripe PaymentIntent API

Make sure you've connected your Stripe account first.

When using Stripe Elements with the PaymentIntent API, pass metadata with datafast_visitor_id and datafast_session_id (cookies from DataFast) 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: {
      datafast_visitor_id: cookieStore.get('datafast_visitor_id')?.value,
      datafast_session_id: cookieStore.get('datafast_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, DataFast 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 marc@datafa.st.

Something missing? Suggest features ✍️