Track revenue
Capture payments as revenue events — and link each sale to the visitor who made it, with a one-line script call on your success page or automatically through your connected payment provider.
statiz records every completed payment as a revenue event — the amount, the currency and, when linked, the visitor who paid. This lets you:
- See exactly how much money your traffic makes — the Revenue and Revenue/Visitor tiles on your dashboard.
- Attribute revenue to channels, campaigns, countries and pages through the paying visitor's first session (first touch).
- See who paid — paying visitors appear as avatars on the main chart and carry a lifetime
Spentamount in the Goals card. - Keep the books honest — refunds land as negative amounts and net out automatically.
You can track revenue with two methods:
statiz.revenue() and a provider webhook for the same payment each record it as a separate event, so using both doubles your revenue. If you can connect a payment provider, Method #2 is the recommended path: it is server-side (ad blockers can't touch it), refunds are recorded for you, and nothing depends on the success page loading. Keep Method #1 for sites with no connected provider.Method #1: Client-side tracking with JavaScript
Call statiz.revenue() where the payment is confirmed — typically your success page, after the provider redirects the customer back:
1<!-- On your success / "thank you" page, after the payment is confirmed -->2<script>3 // name + email are optional — they replace the visitor's generated4 // display name and show the payer's email in the User/Journey tabs5 statiz.revenue({ amount: 9, currency: "USD", plan: "pro",6 name: "Jane Doe", email: "jane@example.com" });7</script>Rules for the statiz.revenue() call:
amount— a positive number in major units:9for a $9.00 payment, never cents.currency— optional 3-letter ISO 4217 code, defaults to"USD".plan— optional label for the plan or product, stored with the revenue event.name/email— optional payer identity. When set, the visitor's generated display name is replaced with the real name and the email shows in small text under it in the User and Journey tabs. Payments from the same email group under one identity.- Call it once per payment, on the success page — not when the checkout opens.
No extra wiring is needed for attribution: the tracker attaches the same visitor id it uses for every pageview, so the payment links to this visitor's sessions automatically.
Method #2: Automatic tracking with your payment provider
Connect Stripe, Polar, Creem, Dodo Payments, Paddle or Lemon Squeezy and statiz records payments as they happen — no tracking code on your side.
- Open Settings → Revenue on your site's dashboard and pick your provider — the panel walks you through creating the webhook in the provider's dashboard and pasting the API key + signing secret.
- That's it for totals. statiz verifies every webhook delivery against the signing secret and records:
- completed payments and subscription renewals, in real time
- refunds as negative events, so revenue always nets out
- "Sync now" backfills up to 365 days of history — and every transaction is stored exactly once, so webhooks and syncs never double-count
- the payer's name and email whenever the provider carries them — historical payers appear in the User and Journey tabs as real customers (with exact payment dates), not just numbers. If you connected before this existed,
Re-import payment historyin the same panel re-fetches the window and fills the identities in — nothing is deleted or double-counted.
Every provider has its own illustrated step-by-step guide — the exact dashboard path, the events to select, where the signing secret lives, and screenshots of every step: Stripe · Polar · Creem · Dodo Payments · Paddle · Lemon Squeezy.
Per-visitor views — avatars on the chart, Spent, channel and country attribution — need one tiny extra step: telling statiz who is checking out. That's the next section.
Link payments to visitors
The checkout itself happens on your payment provider's domain, where statiz has no cookies and stores no IPs — so the only reliable bridge is to stamp statiz's visitor id into the checkout when you create it. The id travels with the provider's metadata and comes back on the webhook:
How a payment gets attributed
- 1
statiz.visitorId()Your buy button reads the visitor id the tracker already set in this browser
- 2
metadata.statz_visitor_idYour server stamps it into the checkout session it creates at the provider
- 3
checkout.completedThe provider's webhook delivers the payment — with the metadata — to your statiz site
- 4
revenue → visitorstatiz validates the id against visitors the site has really seen, then attributes the payment
Grab the id on your buy button with statiz.visitorId() — the same id the tracker has been using for this visitor all along (it lives in localStorage as statz_vid):
1// Your buy button — send statiz's visitor id along with the checkout request2document.querySelector("#buy-pro").addEventListener("click", async () => {3 const res = await fetch("/api/create-checkout", {4 method: "POST",5 headers: { "Content-Type": "application/json" },6 body: JSON.stringify({7 plan: "pro",8 statz_visitor_id: statiz.visitorId(),9 }),10 });11 const { url } = await res.json();12 window.location.href = url; // off to the provider's hosted checkout13});Then include it in the checkout your server creates. statiz looks for one metadata field — statz_visitor_id:
1// POST /api/create-checkout on your server — Creem example2const res = await fetch("https://api.creem.io/v1/checkouts", {3 method: "POST",4 headers: { "x-api-key": process.env.CREEM_API_KEY },5 body: JSON.stringify({6 product_id: "prod_123",7 success_url: "https://yourwebsite.com/success",8 metadata: {9 // the bridge: rides along on every webhook for this purchase10 statz_visitor_id: body.statz_visitor_id,11 },12 }),13});14const { checkout_url } = await res.json();15return Response.json({ url: checkout_url });Where each provider carries the hint:
The hint does one more thing: it merges the payer's history. Payments statiz already recorded for that customer's email — including everything backfilled from the provider, before your site ever tracked them — move onto the tracked visitor the first time a checkout carries both the hint and the same email. One customer, one row, full payment history.
Viewing revenue in statiz
Once payments flow in, revenue shows up across the whole dashboard:
- Open your dashboard — the Revenue and Revenue/Visitor tiles show totals with their delta vs the previous period, plus MRR (net revenue over the trailing 30 days) and ARR (MRR × 12).
- Click the Revenue tile — the chart switches to revenue bars, and paying visitors appear as avatars pinned to the curve for the buckets they paid in; several payers in one bucket collapse into one avatar with a
+Nchip. Clicking an avatar opens that visitor's full history. - Open the Goals card → User tab — the
Spentcolumn shows each visitor's lifetime net revenue (refunds subtracted), and known payers show their real name with the email underneath. The Journey tab shows the same for visitors who completed the selected goal — the built-in Payment journey lists every customer with an attributed payment, date-filterable like everything else. - Toggle any breakdown card — Channels, Locations, Pages, Devices — into Revenue mode: every row gains the revenue attributed through the paying visitor's first session, so you can see which channel, country or entry page the money came from.
Notes & caveats
- Pick one method per sale.
statiz.revenue()and a provider webhook for the same payment record it twice — the two events share no id to dedupe on. The webhook is the source of truth; keep the script call for sites with no connected provider. - Client-side can be blocked. Ad blockers and abandoned redirects lose Method #1 events; webhooks never do.
- Unattributed payments still count. Checkouts created directly in the provider's dashboard (or with a bad hint) feed Revenue, Revenue/Visitor, MRR and the chart — payments with no payer email simply don't appear in per-visitor views.
- What statiz stores about a payment. The amount, currency, the provider's transaction id, and — when your checkout or the provider provides them — the payer's name and email (your own customer data, used to group their payment history). Never card numbers or bank details; API keys and webhook secrets are encrypted at rest.
Set up with AI
You don't have to wire this by hand. Copy the prompt for the one method you picked — remember, never both — and paste it into an AI coding agent that can edit your website's code.
1I want to track revenue with statiz analytics, whose <script> beacon is already installed on this site. Do NOT add any payment-provider integration — this site will use the client-side method ONLY.23Add a one-line revenue call:451. Find the page shown AFTER a successful payment (the success / thank-you page, or the route the payment provider redirects back to).62. On that page, call exactly once per completed payment:7 statiz.revenue({ amount: 9, currency: "USD", plan: "pro", name: "Jane Doe", email: "jane@example.com" })8 - amount: a number in MAJOR units (9 = $9.00 — never cents)9 - currency: optional 3-letter ISO 4217 code, defaults to "USD"10 - plan: optional label for the plan/product11 - name/email: optional payer identity — replaces the generated display name and shows the email under it in the User/Journey tabs; omit when the checkout doesn't expose them123. Read the real amount when it is available on the client (e.g. a success-URL query parameter the provider appends); otherwise use the plan's known price.134. In React, call it inside a useEffect that runs once after the payment is confirmed (guard against remounts so it can never fire twice for one payment). In plain HTML, a small <script> on the success page.145. NEVER call it on the checkout button click or the checkout page — only after payment is confirmed.156. Do not modify the statiz tracker snippet itself.1617Replace the placeholders with this site's real plan names and prices. When done, list every file you changed and show the exact call you added.After deploying, make a test purchase and open your statiz dashboard — the payment appears in the Revenue tile within seconds, and with Method #2 the paying visitor's avatar lands on the chart curve.