Revenue Analytics
The funnel Revenue tab — what each number means, how revenue is attributed to a session, the cohort and cash lenses, ad spend and ROAS, and what agents can read.
Every funnel page has a Revenue tab next to Sessions. Sessions is the live, per-session view; Revenue answers "what did this funnel earn, and from whom": KPIs against the previous period, a step funnel, revenue over time, cohort LTV, a breakdown by any dimension with spend and ROAS, and an arm comparison for a funnel experiment. Web and native funnels use the same tab.
The tab reads six independent sections, each its own route under
/dashboard/projects/:projectId/funnels/:funnelId/revenue/
(apps/api/src/routes/dashboard/funnel-revenue.ts): summary, steps,
series, cohorts, breakdown and arms, plus
/dashboard/projects/:projectId/funnels/revenue/compare (one row per funnel
of the project). Each answer is cached in Redis for 60 seconds
(REVENUE_ANALYTICS_CACHE_TTL_S); any spend write empties the project's
cache at once.
Revenue analytics needs ClickHouse. A deployment without it answers every
section with { available: false } and the tab shows "No analytics store";
ad spend lives in Postgres and keeps saving.
The unit: a funnel session
Everything is counted per funnel session — one run of the funnel, the
sessionId of raw_funnel_events. Visitor-level counting, and every
statistical verdict, belongs to the experiment results page. Bot sessions
are left out of every number and counted in the diagnostics footer.
Attribution: forever, to the session
A revenue row belongs to the funnel session it carries in
raw_revenue_events.funnelSessionId. The purchase stamps it, and every
later row of the same purchase inherits it:
- Web funnels — Stripe subscriptions, their renewals, trial charges and refunds all carry the session that sold them.
- Native funnels — the app reports the session in the purchase's
presented context. Apple and Google renewal, trial-conversion,
reactivation and refund rows copy the original purchase's context
(
withInheritedPresentedContext,apps/api/src/lib/presented-context.ts), looked up by the store's original transaction.
There is no attribution window. A renewal a year later still counts for the session that sold the subscription. Time is bounded only by the lens and by cohort age (below).
Revenue of a funnel whose row names no session of it — history from before the session stamp, a row written by the previous release during an upgrade, a native purchase whose session never reached ClickHouse — is not dropped. It is shown as revenue not attributed to a session in the diagnostics, and is part of the cash-lens series. It is left out of the session KPIs, the steps, the breakdowns and the cohorts, because no session carries it.
"Initial purchase only" on native funnels
When a native funnel is in scope and no inherited renewal, trial
conversion, reactivation or refund row of it exists in the range, the
response carries nativeInitialOnly: true and the tab shows an Initial
purchase only badge on the KPI row and on the breakdown rows. Store rows
written before renewals inherited the funnel context (and rows written by a
previous release during an upgrade) carry no session, so for such a range
only the first purchase counts. As soon as the range holds an inherited row,
the badge goes away.
Two lenses, never mixed
| Lens | Used by | Which revenue |
|---|---|---|
| Cohort | KPIs, steps, cohorts, breakdown, arms, ROAS | Sessions that started in [from, to), and all their revenue up to the as-of instant |
| Cash | Revenue over time | Revenue rows whose transaction date is in the range, for the funnel's sessions whatever their start, plus the unattributed rows |
asOf defaults to now and is echoed in every answer. In production it is
never later than now. In sandbox it may reach the latest instant a Stripe
test clock has written revenue at, so a renewal on an advanced test clock
becomes visible when you ask for it; a later asOf is clamped, and the
clamp is what is echoed (resolveRevenueAsOf).
The previous period is the range of the same length just before it,
with its revenue cut at the same age: its as-of is asOf − (to − from).
An older cohort with more time to renew would otherwise always look better.
All days are UTC: the range, the series buckets, cohort weeks, and spend days.
Metric definitions
S is the non-bot sessions of the funnel, environment and filters whose
start is in [from, to). Revenue rows are read deduplicated
(raw_revenue_events FINAL, the outbox is at-least-once) in the session's
environment, up to asOf. Purchase-class types are INITIAL, RENEWAL,
TRIAL_CONVERSION, REACTIVATION, NON_RENEWING_PURCHASE and
CREDIT_PURCHASE; refund amounts are stored positive and subtracted.
| Metric | Formula |
|---|---|
| Sessions | ` |
| Gross | Σ amount of purchase-class rows with amount > 0 |
| Refunds | Σ REFUND amounts |
| Net revenue | Gross − Refunds |
| Proceeds | Net after the store commission, over rows that have a commission rate; net without a rate is reported apart as unratedNet, never estimated |
| Paying sessions | Sessions with at least one purchase-class row with amount > 0 (a $0 trial start does not count) |
| Conversion | Paying sessions ÷ Sessions |
| Checkout conversion | Sessions that paid ÷ sessions with funnel.session.checkout_started; — (checkoutTracked: false) until a session of the funnel carried that event |
| ARPU | Net ÷ Sessions |
| ARPPU | Net ÷ Paying sessions |
| Trial starts | Sessions with a $0 INITIAL row |
| Trial → paid | Sessions with a TRIAL_CONVERSION row > 0 ÷ trial starts whose trial has ended by asOf; trials still running are left out of both and counted as trials in progress |
| Refund rate | Refunds ÷ Gross (money); refundedSessionRate is refunded paying sessions ÷ paying sessions |
| Renewal share | Σ RENEWAL ÷ Gross |
| Step arrival | Sessions that reached the page ÷ Sessions |
| Step to step | Arrivals at the page ÷ arrivals at the previous page — only when every route to the page passes the previous one in that version's graph; otherwise — (a page after a branch can have more arrivals than the page before it) |
| LTV at age d | Net of revenue before start + (d + 1) days, ÷ cohort sessions (or ÷ paying sessions at that age, "per payer"). Day 0 is the first 24 hours |
| Spend | Σ of the matched funnel_ad_spend rows |
| ROAS | Net revenue (USD) of the sessions the spend matches ÷ spend (USD); null without spend |
| CAC proxy | Spend ÷ paying sessions the spend matches |
A ratio whose denominator is 0 is null, shown as —.
Steps are per version: the current published version by default, or All versions, which unions pages by id and marks the ones that are not in every version. The milestones under the steps are checkout started, paid, trial started and trial converted.
Cohorts are rows by first-session ISO week (UTC), at ages 0, 7, 14,
30, 60, 90, 180 and 365 days (LTV_AGES_DAYS). A cell is mature only
when every session of the week has reached that age by asOf; a younger
cell shows its value so far, greyed and labelled "maturing", and is never
extrapolated.
The breakdown groups by any dimension of the filter bar (funnel, version,
experiment, arm, allocation revision, country, OS, browser, in-app browser,
traffic, network, UTM source, medium, campaign). It returns the 50 keys
with the most sessions (BREAKDOWN_TOP_N) and folds the rest into
(other). Export CSV saves exactly the rendered rows.
Production and sandbox
Every section takes env=production|sandbox (default production; an empty
value is production). The two are never mixed. A session's environment is
the environment of its paid event when it paid, otherwise of its start — a
session that opened unscoped and paid live is production. Revenue rows keep
their own environment. The diagnostics count the sessions that fell in the
other environment.
Display currency
Money is stored in USD, converted at the transaction's date when it is
written. With currency=EUR (or any display currency), each row converts at
its own day's rate, and the answer carries fxSource: "ecb-daily" — so a
past month never moves when today's rate does. Spend converts at its spend
day's rate the same way (see Display currency).
Ad spend and ROAS
Open Ad spend from the tab. Spend is stored per funnel × UTC day ×
network × optional campaign in Postgres (funnel_ad_spend), entered by
hand or imported from CSV. ROAS and CAC appear only where spend exists;
everywhere else they are —, never 0.
Matching. A spend row matches the funnel's sessions that started on its
day from its network. When the row names a campaign it also has to equal
the session's utm_campaign, after the same normalisation UTM values get
(lowercase, trimmed, at most 64 characters). A row without a campaign covers
the whole network that day. A session matched by two rows counts once.
Spend that matches no session is listed under Spend with no matching
sessions — "no session came from this network that day", or "no session
carried utm_campaign = X" — so a misspelt campaign is visible instead of
silently lowering ROAS.
Validation (validateAdSpendRow, apps/api/src/services/funnel/ad-spend.ts):
day— a calendar dateYYYY-MM-DD, UTC, not in the future.network— one ofmeta,tiktok,google_ads,apple_search_ads,snapchat,unity,applovin,ironsource,x,reddit,other(case-insensitive).campaign— optional, at most 512 characters before normalisation; a value that looks like an email address or a phone number is refused.amount— a positive decimal, at most 10 integer digits and 4 decimals.currency— an ISO 4217 code. USD amounts are stored as is; any other currency is converted at the spend day's rate. A day whose rate is not imported yet shows "no FX rate yet" and counts once the daily rate import fills it (that import also empties the revenue cache).
A row on an existing day + network + campaign replaces its amount. Every
write is audited (funnel.ad_spend.upserted, funnel.ad_spend.deleted)
in the project's audit log.
CSV format
day,network,campaign,amount,currency
2026-11-03,meta,spring,50.00,USD
2026-11-03,tiktok,,30.00,EUR- A header line first; columns in any order;
campaignmay be left out. - A UTF-8 byte order mark and Windows line endings are accepted; fields may be quoted (RFC 4180), with doubled quotes inside.
- At most 500 rows (
AD_SPEND_MAX_ROWS_PER_REQUEST) and 256 KB. - All or nothing. The whole file is checked first; one bad line imports
nothing, and every line's error comes back (
Line 4 · currency: …). The same day + network + campaign twice in one file is an error on the later line. Importing a corrected file again replaces amounts, it never duplicates.
Download template in the drawer gives this file.
Comparing experiment arms
With an experiment selected, arms shows the metrics per arm with the
change against control and a breakdown by allocation revision. The arm is
read from the session, so a refund lands on the arm that sold the purchase.
This view is descriptive; it differs from the experiment's results page in
three ways, which the tab states in a banner:
- Window — results count conversions inside the experiment's attribution window; this tab counts all revenue up to the as-of instant.
- Unit — results count visitors; this tab counts sessions.
- Revision — results judge the current allocation revision only (and production data by default); this tab spans every revision, filterable.
The verdict stays on the results page.
UTM values
utm_source, utm_medium and utm_campaign reach ClickHouse for the
breakdown, after normalizeUtmValue (@rovenue/shared/funnel):
percent-decoded (an undecodable value becomes (redacted)), checked for an
email address or a phone number — a match replaces the whole value with
(redacted), and a value of digits only is never taken for a phone number,
so numeric campaign ids survive — then lowercased, trimmed and cut to 64
characters. The check runs before the cut, so a cut cannot hide a match.
utm_term, utm_content and click ids never leave Postgres.
One-click upsells
A one-click upsell is charged as its own Stripe
payment or subscription, but its revenue rows carry the funnel session of
the first payment (apps/api/src/services/funnel/complete-upsell.ts:95-108).
It therefore counts toward that session's revenue and the session's
experiment arm, like a renewal does. It is not reported apart from the first
payment.
Take rate is not shown yet. No dashboard section, route or agent tool
reports how many buyers accepted an offer. The data is recorded: every offer
writes funnel.upsell.shown, funnel.upsell.charged and the rest of the
family to raw_funnel_events, with the offer in offerKey and, on
charged, the purchase in purchaseId
(packages/db/clickhouse/migrations/0050_funnel_upsell_events.sql:48-54).
Take rate per offer is charged / shown over those rows, and an offer's
revenue joins raw_revenue_events.purchaseId to that purchaseId. Rows
written before migration 0050 ran have an empty offerKey.
Privacy and deletion
- Every answer is an aggregate: no session id, visitor, subscriber, email or a single session's UTM value is returned. The Sessions tab keeps its own per-session view.
- These are first-party aggregate analytics; the visitor's
analyticspixel consent governs third-party pixels, not this tab. - ClickHouse keeps a per-session rollup,
funnel_session_facts(a session id and coarse dimensions). A data subject erasure deletes the subject's rows from it by their session ids, read before the raw event rows are deleted; deleting a project purges it. Its revenue rows go with the existing revenue erasure. - Ad spend is your business data, not personal data. It is deleted with its funnel or project, and every change is in the audit log.
Agents: MCP and the copilot
The same three operations are available to agents, through the same query
validation, membership check, ownership checks, cache and spend validation
as the dashboard routes (apps/api/src/services/funnel/revenue-agent.ts) —
an agent reads exactly the numbers the tab shows. Only project members
reach them.
| MCP tool | Copilot tool | Does |
|---|---|---|
get_funnel_revenue_analytics | query_funnelRevenue_get | One section (summary, steps, series, cohorts, breakdown, arms) with the tab's parameters as JSON: funnelId, from, to, asOf, env, currency, versionId, experimentId, granularity, per, ages, groupBy, filters |
list_funnel_ad_spend | query_funnelAdSpend_list | The spend rows of a funnel over [from, to] (UTC days) |
upsert_funnel_ad_spend | action_funnelAdSpend_upsert | Enters spend rows, all or nothing, audited |
The read tools' descriptions state both lenses and that ROAS is null
without spend, so a model says "no spend entered" instead of inventing a
number. upsert_funnel_ad_spend needs a read_write MCP token and the
ADMIN role, and runs as an intent executed in the same call; a read token
is refused before anything is recorded. In the copilot, the spend action is
proposed as an intent and writes nothing until you approve it. Answers pass
the copilot's PII masking (an email or phone number in, say, a funnel name
comes back masked).