← All integration guides

Revenue tracking

Send subscription events and read them next to product traffic.

Identify the person first

Revenue rows attach to the same id you pass to identify() in the tracker. That value is stored as the session's identified user. Anonymous sessions are not included in MRR or revenue per visitor.

Premium projects create an API key in Settings. Send it as Authorization: Bearer on every request. The project is taken from the key, so the body does not include a project id.

window.analytica.push(["identify", "user_42"]);

POST a subscription event

POST /api/v1/revenue/subscription-event accepts JSON. amount and mrrDelta are integers in cents. currency is a 3-letter code and defaults to USD. eventType is one of subscription_created, subscription_updated, subscription_cancelled, payment_success, or refund. userId must match the identified user, up to 128 characters.

Those fields map to the stored columns user_id, event_type, amount, currency, and mrr_delta. Forward a Lemon Squeezy or Stripe webhook from your server by translating its payload into this shape. Analytica does not receive billing webhooks directly, and it does not store card numbers.

Net MRR growth on the Revenue tab is the sum of mrr_delta in the selected range. ARPU is ending active MRR — users whose cumulative mrr_delta is still positive — divided by that user count. Gross volume is the sum of positive amount values. The tab is Premium only.

curl -X POST https://app.example.com/api/v1/revenue/subscription-event \
  -H "Authorization: Bearer ana_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_42",
    "eventType": "payment_success",
    "amount": 2900,
    "currency": "USD",
    "mrrDelta": 2900
  }'