# Revenue and attribution

> How Supametrics credits each Stripe payment to the visit that brought the buyer, and what the Revenue screen and the revenue figures on the dashboard show.

Source: https://supametrics.io/docs/revenue

Once Stripe is connected (see [Connect Stripe](https://supametrics.io/docs/connect-stripe)), every paid payment is credited to a
visit: the source, campaign and landing page that brought the buyer. That is what lets the dashboard rank
sources and pages by the money they bring, not just by visitors.

## The Revenue screen

The **Revenue** screen is at `/revenue` (for example https://app.supametrics.io/revenue): **Payments** in the
left rail, or the **Stripe** row on the **Setup** screen (**Set up** or **Manage**). The same Stripe setup is also in **Site settings › Revenue**.

It always covers the **last 30 days**, in your website's currency, for one-time and subscription payments.

### Summary

- **Payments, 30 days**: paid payments counted toward revenue (refunds are not counted as payments).
- **Revenue, 30 days**: the total, net of refunds unless you turned **Subtract refunds from revenue** off.
- **Unattributed revenue**: the share of revenue that couldn't be linked to a visit, with how much money and
  how many payments that is. When it's above 20%, a warning says what share of revenue came from payments
  without a visitor ID and points you to step 1 of the setup.
- **Currency**: your website's currency. Other currencies are listed, not counted.

### Revenue by day and top sources

Once there is at least one payment, the screen shows:

- **Revenue by day** over the last 30 days.
- **Sources by revenue**: sources ranked by the revenue credited to them.
- **Pages by revenue**: landing pages ranked by the revenue credited to them.

Click a source or page to open the dashboard filtered to it.

### Setup and connection

**Set up Stripe payments** lists the four setup steps and how many are done, and **Connection** shows the
connection status, the **Last verified webhook**, the **Last rejected** webhook (if any), the masked signing
secret with **Replace or disconnect**, and notes about test-mode payments and payments in other
currencies. See [Connect Stripe](https://supametrics.io/docs/connect-stripe).

### Latest payments

The ten most recent payments (refunds aren't listed here), whatever their date, with:

- **When** and **Amount** (in the payment's own currency).
- **Status**: **attributed**, **direct** or **unattributed**, plus a **Test** badge for Stripe test-mode
  payments and **Not counted** with the currency code for payments in another currency.
- **Source**: the source credited, or **No visitor ID on this Checkout** for an unattributed payment.

## How a payment is linked to a visitor

The tracking script gives each visitor an ID, kept in a first-party cookie for a year. You read it on your
site with `window.analyticsx?.('visitorId')` and pass it to Stripe. Supametrics reads it from the payment:

| Payment | Where the visitor ID is read |
|---|---|
| Checkout Session (one-time) | `metadata.ax_visitor_id`, else `client_reference_id` |
| Payment Link | `client_reference_id` |
| PaymentIntent (Payment Element and custom flows) | `metadata.ax_visitor_id` (untagged PaymentIntents are ignored) |
| Subscription invoice | the subscription's `metadata.ax_visitor_id`, else the visitor ID of the Checkout Session that started the subscription, else one from another subscription of the same Stripe customer |

Supametrics does **not** match payments to visitors by email address or Stripe customer details. Without a
visitor ID, the payment is **Unattributed**. The exact code for each case is in
[Connect Stripe](https://supametrics.io/docs/connect-stripe#1-pass-the-visitor-id-into-the-payment).

## How credit is decided

Attribution is decided **once, when the payment arrives**, and saved on the payment. Later visits never
change it.

1. **No visitor ID, or one Supametrics has never seen**: the payment is **Unattributed**.
2. **The visitor had a visit from a source** (search, social, AI, email, a referring site or a tagged
   campaign link) **in the 30 days before paying**: the payment is **attributed** to the most recent such
   visit, with its source, channel, campaign and landing page.
3. **Otherwise** (only direct visits in those 30 days): the payment is credited to **Direct/None**, with the
   landing page, location and device of the visitor's latest visit.

### First touch or last touch?

Supametrics uses **last non-direct touch** within a 30-day window. Direct visits don't take credit away from
the campaign or referral that brought the visitor earlier: someone who clicked your tweet and came back
directly a week later to pay is credited to the tweet. There is no first-touch option.

### Subscriptions and renewals

- The first paid invoice of a subscription is **new** revenue, attributed as above.
- Later invoices are **renewals**. A renewal keeps the attribution of the subscription's first payment, so
  it stays with the source that won the customer, months later.
- If the invoice arrives before the Checkout Session that carries the visitor ID, it is stored as
  Unattributed first and credited as soon as the Checkout Session arrives.
- Trial and zero-amount invoices are not counted.

## Refunds

Each refund is stored as a negative amount **on the date the refund was issued**, credited to the same
source, campaign, landing page and product as the payment it refunds. A refund issued this month for a
payment made last month lowers this month's revenue and leaves last month's as it was.

- Partial refunds subtract only the refunded amount.
- A refund that fails or is canceled counts as zero.
- A refund for a payment Supametrics never recorded is ignored.
- If Stripe reports the same refund through several events, it is subtracted once.
- **Site settings › Revenue** › **Subtract refunds from revenue** (on by default) turns this off: revenue is
  then gross, and refunds aren't shown.

The dashboard's revenue figure splits into **New**, **Renewal**, **Refunds** and **Net**.

## Currencies

Revenue is counted in one currency per website, set in **Site settings › Revenue**. Payments in other
currencies are stored but not counted anywhere, and nothing is converted. If you change the currency, only
payments in the new currency count, including past ones. See
[Connect Stripe](https://supametrics.io/docs/connect-stripe#currency).

## What counts toward revenue

A payment counts when all of these hold:

- It is paid (a Checkout Session with payment status paid, a tagged PaymentIntent that succeeded, or a paid
  subscription invoice).
- It is in your website's currency.
- It is a live payment, or the website has had no live payment yet (test-mode payments count only until the
  first live one).
- Its product isn't unticked in the **Product filter**. Payments that name no product always count; most
  one-time Checkout payments name none.
- It is not a renewal while **Include renewal revenue in KPIs** is off.

A payment is dated when its Checkout Session or PaymentIntent was created in Stripe, and a subscription
invoice when it was paid. Days follow your website's timezone.

## Unattributed payments

Unattributed payments are real money: they are included in total revenue on the dashboard and on the
Revenue screen. But they have no visit, so:

- In breakdowns by source, page or location, they are grouped as **Unattributed**.
- As soon as you apply **any** dashboard filter, they drop out, because they can't be said to match one.
- They aren't linked to a visitor, so they don't count toward paying visitors or Payment conversion.

Common causes: the visitor ID isn't passed to Stripe, the buyer's browser blocked the script, the visitor
hadn't given consent yet (with `data-consent="required"`), or the payment was made somewhere the script
doesn't run.

## Revenue on the dashboard

- **Revenue** in the key figures is the net revenue in the period, split on hover into **New**, **Renewal**,
  **Refunds** and **Net**.
- **Conversion rate** is paying visitors divided by all visitors in the period.
- **Revenue/visitor** is revenue divided by visitors.
- The main chart shows revenue as bars under the visitor line. With no Stripe connection it says **Connect
  Stripe** and links to **Site settings › Revenue**.
- Breakdown cards (sources, pages, locations, devices) can be sorted by revenue. Revenue in a row is what
  was credited to visits matching that row.
- Filters apply to payments through their credited visit: filtering to a source shows the revenue credited
  to that source.

See [The site dashboard](https://supametrics.io/docs/dashboard), [Metrics glossary](https://supametrics.io/docs/metrics-glossary) and
[Sources, pages, locations and devices](https://supametrics.io/docs/breakdowns). The **Revenue** lens of
[Details pages](https://supametrics.io/docs/details-pages) has the same numbers over any date range, and journeys ranked by
revenue are in [Journeys and funnels](https://supametrics.io/docs/journeys-and-funnels).

## Common questions

**Why is a payment credited to a source the buyer didn't use on the day they paid?** Credit goes to the most
recent visit that came from somewhere in the 30 days before paying, not to the paying visit if that one was
direct.

**I changed my UTM tags. Will old payments move?** No. Attribution is saved on the payment when it arrives.

**Why does revenue on the Revenue screen differ from the dashboard?** The Revenue screen always shows the
last 30 days with no filters. The dashboard follows its date range and filters.
