Hybrid Workspace

Metrics

How to calculate MRR for a Shopify app from Partner API events

The Partner API has no MRR field, only what happened. How to replay app events into MRR, the edge cases that skew it, and why it won't match payouts.

· 4 min read

Ask the Partner API how much recurring revenue your app makes and it has no answer: there is no MRR field. What it gives you is a history. Every install, uninstall, plan accepted, plan cancelled and store closed is an event with a shop and a time. MRR is what you get when you replay that history, store by store, and add up where each store ended.

This guide shows how, and where the replay goes wrong if you take the events at face value.

What the Partner API gives you

Each app has an events connection. You can filter it by types, by shop, and by time with occurredAtMin and occurredAtMax, and page through it. The event types that matter for MRR:

Event typeWhat it means for MRR
RELATIONSHIP_INSTALLEDA store installed the app. No money yet
SUBSCRIPTION_CHARGE_ACTIVATEDA plan is active: the store's MRR becomes that charge's price
SUBSCRIPTION_CHARGE_CANCELEDThe plan ended: the store's MRR goes to zero
SUBSCRIPTION_CHARGE_FROZEN / UNFROZENThe store stopped paying Shopify: zero while frozen, the same plan back when it unfreezes
RELATIONSHIP_DEACTIVATED / REACTIVATEDThe store closed or paused: zero while closed, back when it reopens
RELATIONSHIP_UNINSTALLEDThe store removed the app: zero
SUBSCRIPTION_CHARGE_DECLINED / EXPIREDA plan was offered and never accepted: nothing changes
ONE_TIME_CHARGE_*, USAGE_CHARGE_APPLIEDReal revenue, but not recurring: never in MRR

What you get paid is a different query: transactions, the lines of your payouts, each with what was billed and what is paid to you after Shopify's share.

The replay

  1. Read every event for the app, oldest first, and keep them. Read again on a schedule from the last time you read, with occurredAtMin, rather than starting over.
  2. Group by shop and walk each shop's events in order, keeping one number per shop: what it pays a month now.
  3. Apply each event as in the table above.
  4. Add up the shops that have the app installed today. That is MRR.

Because the state per shop is rebuilt from the whole history, a rule you change later (say, how yearly plans count) can be applied to every past month too, by replaying again.

The edge cases that skew it

  • Plan changes can arrive as two events in the same second. In our apps' data, Shopify activates the new charge and cancels the old one at the same time. If you apply them in the wrong order, the cancellation wipes the new plan and the store shows as paying nothing. Treat a cancellation as ending only the charge it names.
  • Yearly plans. A yearly subscription's price is a year's price; counted as monthly, it multiplies MRR by twelve for that store. Divide it by twelve. Check how your events tell you a plan is yearly, and handle the case where they don't.
  • Test charges and review stores. Development stores and App Review create real-looking charge events whose charge has test set. Leave them out, or the week of your review looks like growth.
  • Free trials. A charge activates when the merchant accepts the plan, trial or not. Counting it from that day is a defensible choice, but say so, and show trials separately when you compare MRR with payouts.
  • Frozen and closed stores. A store that stops paying Shopify, or closes for a while, is not a merchant who left. Set it to zero and keep the plan aside, so it comes back if the store does.
  • Currencies. Charges carry their own currency. Add them up as they come and say so, or convert at a dated rate. Never mix the two silently.

Why it won't match your payouts

MRR is a rate: what the stores on a paid plan pay a month today. Payouts are what was actually billed and paid in a month. They differ for reasons you can name:

  • plans started, changed or cancelled during the month;
  • trials that hadn't billed yet;
  • yearly plans billed all at once in the month they renew;
  • one-time and usage charges, which are billed but never in MRR;
  • refunds and adjustments;
  • Shopify's revenue share and processing fee, the difference between billed and paid.

If you put MRR next to transactions month by month and split the difference into those parts, what is left is small. When it isn't, one of your replay rules is wrong, and that comparison is how you find it.

A use case: our MRR method, written down

We built this replay for our own apps' cockpit, and then published the rules: How MRR is counted lists each event and what it does, the yearly-plan rule (the Partner API's events don't say whether a plan is yearly, so we go by the plan's name and say so), and how MRR is set against what Shopify paid.

If you'd rather not build the replay yourself, Hybrid Workspace reads your Partner account and shows MRR, installs and payouts for every app you ship.

Sources

  • shopify apps
  • mrr
  • partner api
  • app events
  • revenue
  • subscriptions