---
title: "How to track revenue by traffic source - Tracwell"
description: "Connect each verified payment to the visit, source and campaign that started it, using session IDs in checkout metadata and a server-side payment webhook."
canonical: "https://tracwell.app/guides/revenue-by-traffic-source"
markdown: "https://tracwell.app/guides/revenue-by-traffic-source.md"
---

[Guides](https://tracwell.app/guides)

# How to track revenue by traffic source

Updated October 15, 2026

Short answer

Capture the visitor’s analytics session ID in the browser, store it in your payment provider’s checkout metadata, and when the provider’s webhook confirms the payment, send the amount and that session ID to your analytics from your server. The revenue is then credited to the source, campaign and landing page of that session, and refunds are subtracted the same way.

## Why traffic and signups are not enough

Visitors and signups show which channels bring people. Revenue shows which channels bring customers. A source that sends fewer visitors can still be your best channel if those visitors pay, and you cannot see that until payments are connected to visits.

## Why browser purchase events are unreliable

- Ad blockers and privacy tools stop some browser events from being sent.
- People close the tab before the confirmation page loads, or pay in a hosted checkout on another domain.
- A browser event cannot prove a payment succeeded, and it never sees refunds or disputes.

Your payment provider is the source of truth, so record revenue from its verified webhook on your server.

## The four steps

1. Collect a session. Your analytics script gives each visit an anonymous ID and a session ID.
2. Attach it to checkout. Send those IDs to your server when the visitor starts checkout and copy them into the checkout’s metadata.
3. Verify the payment. Your webhook handler checks the provider’s signature and reads the IDs back from the metadata.
4. Send revenue. Post the verified amount, currency, transaction ID and session IDs to your analytics with a server-side key.

## Stripe, Dodo Payments and Polar

Each provider lets you attach metadata to a checkout and returns it with the payment. In Stripe, put the IDs on both the Checkout Session and payment\_intent\_data so they are available on checkout.session.completed and payment\_intent.succeeded. Dodo Payments includes checkout metadata in its payment webhooks, and every subscription renewal arrives as its own payment.succeeded event.

## Handle refunds and retries

- Send each refund as its own transaction using the provider’s refund ID, so net revenue stays correct.
- Webhooks are retried. Derive the event ID from the provider’s event rather than a random value, so a retry is never counted twice.
- Keep amounts in the currency’s smallest unit, such as cents, and report each currency separately instead of converting them.

## Which visit gets the credit

Tracwell credits the acquisition context of the session attached to the payment: its source, campaign and landing page. That is the first touch of that session, not necessarily the customer’s first-ever visit. Payments with no matching session stay visible as unattributed, so you can see how much revenue could not be placed.

Attribution shows where paying sessions came from. It does not prove a campaign caused the purchase, and it does not merge visits across devices.

## Set it up in Tracwell

Use Product mode, generate a server key in Settings → Website, and follow the revenue guide for complete Stripe, Dodo Payments and Polar examples. The Revenue report then shows revenue by source, campaign and landing page, with the journey behind each purchase.

## Frequently asked questions

**Do I need a developer to set this up?**

Yes, once. It needs a small change to your checkout endpoint and your payment webhook handler. After that, revenue reports update on their own.

**Can Tracwell import payments directly from Stripe?**

No. Revenue comes from your server, so only verified payments with their attribution context are counted. Tracwell does not connect to payment providers directly.

**What happens to payments without a session?**

They are still recorded and shown as unattributed revenue, so totals stay complete even when a visit cannot be matched.

## Keep reading

- [Revenue setup guide with code](https://tracwell.app/docs/revenue)
- [Revenue attribution](https://tracwell.app/features/revenue)
- [Use UTM parameters for campaigns](https://tracwell.app/guides/utm-parameters)
