How do I see Stripe revenue by traffic source?
Give Stripe the DataFast visitor ID when the customer pays, then let DataFast match the payment to the first visit. Add data-datafast-checkout to a Stripe Payment Link, or set client_reference_id to window.datafast.visitorId when you create a Checkout Session. Payments reported through Stripe Connect or the revenue API then appear per source.
Steps
- Install the tracking script. Place <script defer src="https://datafast.app/js/script.js" data-website-id="YOUR_SITE_ID"></script> on your site.
- Payment Link. Add data-datafast-checkout to the link: <a data-datafast-checkout href="YOUR_CHECKOUT_URL">Buy now</a>. DataFast adds the visitor ID using the provider's supported field.
- Checkout Session. In the browser read window.datafast?.visitorId and send it to your server, then pass it as client_reference_id when creating the session.
- Report the payment. Use Stripe Connect from the site's settings if it is enabled for your account; otherwise send a server-side call to POST /api/revenue with your revenue API key, site_id, amount, currency, visitor_id and an event_id such as the order ID.
Limits
- Stripe Connect is not enabled on every account yet; the revenue API works for Stripe with or without it.
- Use your order ID as event_id so webhook retries never count one payment twice.
- Without the visitor ID the payment is recorded but not attributed.
FAQ
Do I need Stripe Connect?
No. The revenue API accepts a payment from any provider's webhook, including Stripe.
How long does the visitor ID last?
The default script keeps an opaque first-party ID for 30 days, so a purchase in a later session still matches its original source.
Can I use session-only storage?
Yes, add data-storage="session" to the script. Attribution then ends when the browser session ends.
Related
- How do I find out which marketing channel brings in revenue, not just visits?
- How do I attribute LemonSqueezy or Paddle sales to a traffic source?
- Revenue analytics
- Marketing attribution
Markdown version: /solutions/track-stripe-revenue-by-traffic-source.md