Server-side tracking for revenue attribution
DataFast automatically tracks and attributes your revenue to the right marketing channels. When you attribute revenue on the server side, you get the most accurate data.
1. Connect your Payment Provider
Go to your website settings in DataFast and follow the steps to connect your Stripe/LemonSqueezy account.
2. Pass Metadata during Checkout
💳 Stripe
Pass metadata
with visitorId
and sessionId
(cookies from DataFast) when creating a checkout session:
// app/api/create-checkout/route.js
import { cookies } from 'next/headers';
export async function POST() {
const cookieStore = cookies();
const session = await stripe.checkout.sessions.create({
line_items: [...],
mode: 'payment',
metadata: {
visitorId: cookieStore.get('datafast_visitor_id')?.value,
sessionId: cookieStore.get('datafast_session_id')?.value
}
});
return new Response(JSON.stringify({ sessionId: session.id }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
🍋 LemonSqueezy
Pass custom
with visitorId
and sessionId
(cookies from DataFast) when creating a checkout session:
// app/api/create-checkout/route.js
import { cookies } from 'next/headers';
export async function POST() {
const cookieStore = cookies();
const { data, error } = await createCheckout({
storeId,
variantId,
{
productOptions: { ... },
checkoutData: {
...,
custom: {
visitorId: cookieStore.get('datafast_visitor_id')?.value,
sessionId: cookieStore.get('datafast_session_id')?.value
}
}
}
});
Once connected and cookie data is properly passed, DataFast will automatically:
- Track all payments from your Stripe/LemonSqueezy account
- Attribute revenue to the correct marketing channels
No webhook setup is required - DataFast handles everything automatically once you connect your Stripe account and pass the cookie data during checkout.