Revenue tracking
Send revenue from your site or app, or connect Stripe, RevenueCat, Paddle, Lemon Squeezy, Polar, Paystack, PayFast, Flutterwave, Razorpay, Mollie, Gumroad, the App Store or Google Play.
Any event with a revenue amount counts as revenue. It shows on the overview, in Revenue, and in breakdowns, so you can see revenue per source, campaign, country and landing page. There are two ways to send it: from your own code, or straight from your payment provider with a webhook. Provider webhooks are the more reliable of the two: they also catch renewals, refunds and cancellations that never pass through your front end.
From your code
Put revenue (a number) and optionally currency (three letters) in the event properties, or send revenue as a top-level field: a number or { amount, currency }. Without a currency the amount is taken to be in the site currency.
stancelens("event", "purchase", { revenue: 49.0, currency: "USD", plan: "growth" });Other SDKs take the same revenue and currency properties on any event; see each SDK page for its helpers. Pass the user ID you use with identify so the purchase lands on that person's profile.
Currency conversion
Revenue is stored in the site currency (Site settings → General). An amount in another currency is converted through the euro at the rates of the payment's date (UTC). The original amount and currency stay on the event as $original_amount and $currency, the rate date as $fx_date and the rate source as $fx_source.
| Source | Used for | Currencies |
|---|---|---|
ecb: European Central Bank euro reference rates | Every currency the ECB publishes | AUD, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, ISK, JPY, KRW, MXN, MYR, NOK, NZD, PHP, PLN, RON, SEK, SGD, THB, TRY, USD, ZAR |
currency-api: fawazahmed0 currency-api, CC0, daily mid-market rates | Only currencies the ECB doesn't publish | AED, AFN, ALL, AMD, AOA, ARS, AWG, AZN, BAM, BBD, BDT, BHD, BIF, BMD, BND, BOB, BSD, BTN, BWP, BYN, BZD, CDF, CLP, COP, CRC, CUP, CVE, DJF, DOP, DZD, EGP, ERN, ETB, FJD, FKP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HNL, HTG, IQD, IRR, JMD, JOD, KES, KGS, KHR, KMF, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MZN, NAD, NGN, NIO, NPR, OMR, PAB, PEN, PGK, PKR, PYG, QAR, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SHP, SLE, SOS, SRD, SSP, STN, SVC, SZL, TJS, TMT, TND, TOP, TTD, TWD, TZS, UAH, UGX, UYU, UZS, VES, VND, VUV, WST, XAF, XCD, XCG, XOF, XPF, YER, ZMW, ZWG |
- Each currency uses its own source, so a naira payment on a USD site is converted with the currency-api NGN rate and the ECB USD rate, and
$fx_sourceisecb+currency-api. When the two rates have different dates,$fx_dateis the older one. - The site currency can be any currency in the table, including NGN, KES or GHS.
- The currency-api rates are aggregated market rates, not official central bank fixings. For currencies with both an official and a parallel market rate they can differ from either. Before bundling, the rates of 2026-11-24 were compared with two other public sources, and currencies where they disagreed were left out (listed below); rates fetched later aren't checked that way.
- Stancelens ships with the last 90 days of rates from both sources and fetches newer ones at most every 6 hours. If a source can't be reached, the newest rate Stancelens has is used. Set
STANCELENS_FX_REFRESH=0on a self-hosted install with no internet access. - A day without a rate (the ECB publishes none on weekends and holidays) uses the last earlier day's rate. Payments older than the oldest rate Stancelens has use that oldest rate, and
$fx_datesays which one. - An amount in a currency neither source covers isn't converted and doesn't count toward revenue; it stays on the event with
$fx_error: "unsupported_currency". That includes ANG, BGN, CUC, KPW, SLL, SYP, VED, ZWL, left out on purpose because their rate was doubtful or the currency is no longer in use.
Payment providers
Connect a provider under Site settings → Integrations. Each provider gets its own webhook URL for your site, and every request is authenticated the way that provider documents (a signature checked with the secret you paste there, Apple's or Google's own signature, or for Mollie a lookup with your API key) before anything is recorded. Owners and admins can connect providers. The settings page shows when the last event arrived and the last error, and Send test event posts a correctly signed sample to your webhook URL to check the setup without recording anything.
| Event | Recorded when |
|---|---|
purchase | A one-time payment |
subscription_started | The first payment of a subscription |
subscription_renewed | A renewal payment |
subscription_changed | A plan change, with any prorated payment |
subscription_cancelled | The customer cancelled; the subscription runs until the period ends |
subscription_ended | The subscription ended (churn) |
refund | A refund, as negative revenue |
These events have platform server and sdk stancelens-<provider>-webhook. Revenue is what the customer paid, including tax. Subscription events also carry $subscription_id, $plan, $provider and $mrr: the monthly recurring amount in the site currency before tax (an annual plan counts a twelfth per month), and 0 when the subscription ends. Each provider event is recorded once, however many times it's delivered.
Linking payments to people
Pass the Stancelens user ID (the one you give identify) or the SDK's anonymous ID with the checkout. The JavaScript SDK client returns its anonymous ID from getAnonymousId(); the script tag is cookieless and has no stable anonymous ID, so use the user ID there. Once a provider customer has been linked, later renewals and refunds for that customer are linked too. A payment with no link is recorded under its own visitor, <provider>:<customer id>.
| Provider | Where to put the IDs |
|---|---|
| Stripe | Checkout Session client_reference_id (user ID), or metadata.stancelens_uid / metadata.stancelens_vid on the session, subscription_data.metadata or payment_intent_data.metadata |
| RevenueCat | app_user_id: log in to RevenueCat with the same user ID you pass to identify |
| Paddle | customData: { stancelens_uid, stancelens_vid } on the checkout |
| Lemon Squeezy | checkout[custom][stancelens_uid] on the checkout URL, or checkout_data.custom in the API |
| Polar | metadata.stancelens_uid / metadata.stancelens_vid on the checkout, or the customer's external_id |
| Paystack | metadata: { stancelens_uid, stancelens_vid } on the transaction |
| PayFast | stancelens_uid=<user id> (or stancelens_vid=<anonymous id>) in any of custom_str1 to custom_str5 |
| Flutterwave | meta: { stancelens_uid, stancelens_vid } on the payment |
| Razorpay | notes: { stancelens_uid, stancelens_vid } on the order, payment or subscription |
| Mollie | metadata: { stancelens_uid, stancelens_vid } on the payment or subscription |
| Gumroad | ?stancelens_uid=<user id> on the product URL (Gumroad sends it as url_params) |
| App Store | appAccountToken at purchase: it becomes the user ID, so use the same UUID with identify |
| Google Play | Not possible: Google's notifications carry no user ID |
When the provider sends the customer's email and name, they're added to the person's profile. If the site doesn't store personal data (Site settings → Privacy), they're dropped, or the email is kept as a SHA-256 hash when email hashing is on.
const session = await stripe.checkout.sessions.create({
mode: "subscription",
line_items: [{ price: "price_pro_monthly", quantity: 1 }],
client_reference_id: user.id, // the id you pass to stancelens identify
subscription_data: { metadata: { stancelens_uid: user.id } },
success_url: "https://example.com/thanks",
});Stripe
- In Stripe, open Developers → Webhooks, add a destination for your account with snapshot payloads, and paste
https://stancelens.com/api/integrations/stripe/SITE_ID(copy the exact URL from Site settings → Integrations). - Select
checkout.session.completed,checkout.session.async_payment_succeeded,invoice.paid,charge.refunded,customer.subscription.updatedandcustomer.subscription.deleted. - Copy the signing secret (
whsec_…) into Site settings → Integrations → Stripe.
Signatures are checked as Stripe documents (HMAC-SHA256 of the timestamp and body, 5 minute tolerance). One-time Checkout payments count when paid; subscription money counts from invoice.paid, so a subscription Checkout isn't counted twice. Invoices with nothing to pay (trials, full discounts) aren't recorded. Partial refunds are each recorded as the amount refunded that time. Test-mode events are ignored unless you turn on Record test-mode payments.
RevenueCat
- In RevenueCat, open Integrations → Webhooks and add a configuration with the URL
https://stancelens.com/api/integrations/revenuecat/SITE_ID. - Make up a long random value, put it in the Authorization header value field, and paste the same value into Site settings → Integrations → RevenueCat.
- Leave all event types on. Stancelens records
INITIAL_PURCHASE,RENEWAL,NON_RENEWING_PURCHASE,PRODUCT_CHANGE,CANCELLATION,EXPIRATIONandREFUND_REVERSED, and ignores the rest.
This covers the App Store, Google Play, Stripe and every other store RevenueCat handles. Amounts use price_in_purchased_currency with currency, falling back to price in USD. A CANCELLATION with a negative price is a refund; otherwise it means auto-renew was turned off. Free trials are recorded when they convert. Sandbox events are ignored unless you turn on Record test-mode payments.
Paddle Billing
- In Paddle, open Developer tools → Notifications, create a webhook destination with
https://stancelens.com/api/integrations/paddle/SITE_ID. - Select
transaction.completed,adjustment.created,adjustment.updated,subscription.updatedandsubscription.canceled. - Paste the destination's secret key (
pdl_ntfset_…) into Site settings → Integrations → Paddle.
The Paddle-Signature header is checked with a 5 second tolerance, Paddle's own default, so the server clock must be accurate. Refunds are recorded once Paddle approves them. Paddle payloads don't say whether they come from the sandbox, so connect a sandbox destination to a test site rather than your real one.
Lemon Squeezy
- In Lemon Squeezy, open Settings → Webhooks, add an endpoint with
https://stancelens.com/api/integrations/lemonsqueezy/SITE_IDand a signing secret of your choice. - Select
order_created,order_refunded,subscription_created,subscription_updated,subscription_payment_success,subscription_payment_refunded,subscription_cancelledandsubscription_expired. - Paste the same signing secret into Site settings → Integrations → Lemon Squeezy.
The first payment of a subscription is counted from order_created; subscription_payment_success counts renewals and carries the subscription's MRR. Lemon Squeezy doesn't send the billing interval with payments, so Stancelens takes it from subscription_created, or from the gap between two payments; until it knows the interval, that subscription has no MRR.
Polar
- In Polar, open Settings → Webhooks, add an endpoint with
https://stancelens.com/api/integrations/polar/SITE_IDand the Raw format. - Select
order.paid,order.refunded,subscription.canceledandsubscription.revoked. - Paste the webhook secret into Site settings → Integrations → Polar.
Polar signs with Standard Webhooks (webhook-id, webhook-timestamp, webhook-signature, 5 minute tolerance). Refunds include the refunded tax, matching revenue, which includes tax.
Paystack
- In Paystack, open Settings → API Keys & Webhooks and set the webhook URL of the mode you use (test or live) to
https://stancelens.com/api/integrations/paystack/SITE_ID. - Paste the secret key of the same mode (
sk_live_…orsk_test_…) into Site settings → Integrations → Paystack. If you've generated a webhook signing secret (whsec_…), paste that instead.
Paystack sends every event to the one URL. Stancelens checks x-paystack-signature (HMAC-SHA512 of the body with your secret key), or with a whsec_ secret the newer Paystack-Signature header with a 5 minute tolerance. It records charge.success, subscription.not_renew (cancelled), subscription.disable (ended) and refund.processed. A charge for a plan counts as a subscription payment: the first one for a customer and plan starts the subscription, later ones renew it. Refunds land on the person who made the payment. Test-mode events are ignored unless you turn on Record test-mode payments.
PayFast
- In PayFast, set a salt passphrase under Settings → Developer Settings.
- Send
https://stancelens.com/api/integrations/payfast/SITE_IDasnotify_urlwith each payment, from your payment form or the API. - In Site settings → Integrations → PayFast, paste the passphrase and your merchant ID.
Each ITN's MD5 signature is checked with your passphrase, the merchant ID must be yours, and gross minus fee must equal net. Stancelens doesn't know what you charged for an order, so it can't compare amount_gross with your own records the way PayFast suggests; do that in your own ITN handler if you have one. Turn on Confirm with PayFast to also post each notification back to PayFast's validate endpoint and record it only when PayFast answers VALID. PayFast's source-IP check isn't done, since the caller's IP isn't reliable behind a proxy; the validate call covers the same risk. Turn on Sandbox account for a sandbox merchant: confirmations go to sandbox.payfast.co.za and payments count as test payments. Amounts are in rand (ZAR). Subscription payments carry a token: the first one starts the subscription, the rest renew it. PayFast doesn't say when a cancelled subscription's paid period ends, so a cancellation ends it, and its MRR, straight away.
Flutterwave
- In Flutterwave, open Settings → Webhooks, set the URL to
https://stancelens.com/api/integrations/flutterwave/SITE_IDand type a secret hash. - Paste the same secret hash into Site settings → Integrations → Flutterwave.
Flutterwave sends the secret hash in the verif-hash header; nothing is signed, so keep the hash long and private. Stancelens records successful charge.completed payments, subscription.cancelled (ended) and refunds. Flutterwave's refund notification has no currency, so a refund is matched to the payment Stancelens recorded earlier and takes its currency and person; a refund for a payment Stancelens never saw isn't recorded, and the integration shows why. Flutterwave payloads don't say whether they come from test mode, so connect test mode to a test site.
Razorpay
- In Razorpay, open Account & Settings → Webhooks → Add New Webhook with
https://stancelens.com/api/integrations/razorpay/SITE_IDand a secret. - Select
payment.captured,invoice.paid,subscription.charged,subscription.cancelled,subscription.completedandrefund.processed. - Paste the secret into Site settings → Integrations → Razorpay.
X-Razorpay-Signature (HMAC-SHA256 of the body) is checked. Amounts are in paise (or the currency's smallest unit). A subscription's payment also arrives as payment.captured; Stancelens counts it once, from subscription.charged, which also says whether it's the first payment. Razorpay payloads don't say whether they're from test mode, so connect test mode to a test site.
Mollie
- Pass
https://stancelens.com/api/integrations/mollie/SITE_IDaswebhookUrlwhen you create a payment or a subscription. - Paste an API key into Site settings → Integrations → Mollie:
live_…for live payments,test_…for test ones.
Mollie's webhooks aren't signed and only carry a payment ID, so Stancelens fetches the payment from the Mollie API with your key, plus the customer (name and email) and subscription (interval, for MRR). A made-up ID isn't found and nothing is recorded. Mollie calls the webhook again when a payment is refunded or charged back, and those are recorded as refunds. Mollie doesn't call a webhook when a subscription is cancelled, so cancellations aren't recorded; a subscription that stops renewing counts as churned once its period has passed. Send test event checks the API key with Mollie and previews a sample payment.
Gumroad
- In Gumroad, open Settings → Advanced, set the Ping endpoint to
https://stancelens.com/api/integrations/gumroad/SITE_IDand turn on signing. - Paste the ping signing secret into Site settings → Integrations → Gumroad.
Gumroad signs pings to your Ping endpoint with X-Gumroad-Signature (HMAC-SHA256 of the timestamp and body; Stancelens allows 5 minutes). Unsigned pings are rejected, and so are the refund, cancellation and dispute notifications Gumroad's API resource subscriptions send, since those carry no signature. So Gumroad sales and subscription charges are recorded, refunds and cancellations aren't. Gumroad's ping gives the price in US cents whatever the product's currency, so revenue is taken as USD; the product's currency is kept as $product_currency. Your own test purchases are test payments.
App Store
- In App Store Connect, open your app's App Information → App Store Server Notifications, choose Version 2, and set the production and sandbox URLs to
https://stancelens.com/api/integrations/appstore/SITE_ID. - Enter the app's bundle ID in Site settings → Integrations → App Store, and optionally its Apple ID.
Apple signs each notification (JWS, ES256) with a certificate chain that Stancelens checks up to Apple Root CA - G3, as Apple's App Store Server Library does, including Apple's marker extensions and the certificates' dates; then the bundle ID (and Apple ID, when set) must match. Stancelens doesn't check certificate revocation online (OCSP). It records SUBSCRIBED, DID_RENEW, ONE_TIME_CHARGE, REFUND, REFUND_REVERSED, auto-renew turned off (cancelled) and EXPIRED, GRACE_PERIOD_EXPIRED and REVOKE (ended). Revenue is the transaction's price in its currency, the amount the customer paid. Sandbox notifications are test payments. Send test event isn't available, since only Apple can sign; request a test notification with the App Store Server API.
Google Play
- In Google Cloud, create a Pub/Sub topic, give
google-play-developer-notifications@system.gserviceaccount.comthe Publisher role on it, and set it under Play Console → Monetization setup → Real-time developer notifications. - Create a push subscription to
https://stancelens.com/api/integrations/googleplay/SITE_IDwith authentication on: pick a service account, and leave the audience empty (Pub/Sub then uses the push URL) or set your own. - In Site settings → Integrations → Google Play, enter the package name, the service account's email and the audience (the push URL if you left it empty).
Every push carries a Google-signed token; Stancelens checks its signature against Google's published keys, the issuer, the audience, the service account and the expiry, then that the package name matches. Google's notifications say what happened to a purchase token but carry no price, currency or user ID, and Stancelens doesn't call the Play Developer API that has them. So Play events are recorded without revenue, each purchase token as its own visitor: subscription purchases, renewals, cancellations and ends, one-time purchases, and voided purchases as refunds with no amount. They count subscriptions and churn, not money. For Play revenue, use RevenueCat or send purchases from your app.
Refunds
Provider refunds are recorded automatically as refund events with negative revenue. From your own code, send the refund as an event with a negative amount (for example revenue: -49). The Revenue page shows refunds separately and nets them out of net revenue.
Subscriptions and MRR
With a provider connected, the Revenue page adds monthly recurring revenue (MRR), active subscriptions, and MRR movements: new, expansion, contraction, churned and reactivated. They're built from the subscription events above. A subscription whose paid period ended more than 3 days ago with no renewal is counted as churned at that point, in case the provider's end event never arrived. Revenue you send from your own code has no subscription details, so it counts toward revenue but not MRR.