Skip to main content

Read the Analytics Dashboard revenue by tier

Premium Intermediate

What built-in membership collected for the shows in view, per tier, buy-ups and month, one series per currency. It takes show_id, date_from, date_to, an optional tier_slug and scope, with the same permission, 403 and 400 as the other Analytics Dashboard routes. The add-on reads core’s ledger only through benecaster_get_membership_payments(), live mode, and converts with core’s own currency precision, so you never divide by 100.

  • Cash collected, never a monthly rate. Core’s ledger has no billing interval; do not derive MRR/ARR from months.
  • Tax is left out, and buy-ups are buyups, never inside a tier. A refund reduces both in proportion to what was kept and lands on the month of the payment it refunds, so a closed month can fall later. A full refund nets 0.
  • Use decimals to format, and *_minor when you need exact sums: amount is a float for display. Yen have 0 decimals, KWD 3, and UGX and ISK are written whole though core counts them in hundredths; the add-on has already converted them.
  • A month that ended before recorded_since is null: nothing was recorded then, so draw a gap, not 0. recorded_since is install-wide.
  • shows lists every show read with its bridge; a show not on benecaster_builtin contributes nothing. With scope=all each currency sums across the shows where the add-on is active.
  • With tier_slug, only that tier’s payments (and their buy-ups) are read.
  • The filter’s $args are show_ids, date_from, date_to and tier_slug; a non-array return is ignored.

Code

const url = window.benecasterAnalyticsDashboard.apiUrl + 'analytics/revenue?show_id=12&date_from=2026-07-01&date_to=2026-09-30';
const revenue = await ( await fetch( url, { headers: { 'X-WP-Nonce': window.benecasterAdmin.nonce } } ) ).json();
if ( ! revenue.built_in ) {
    // No show in view uses built-in membership: Benecaster cannot see an external plugin's billing.
}
for ( const c of revenue.currencies ) {          // one currency at a time — never add c.total across entries
    const money = new Intl.NumberFormat( undefined, { style: 'currency', currency: c.currency, minimumFractionDigits: c.decimals, maximumFractionDigits: c.decimals } );
    console.log( c.currency, money.format( c.total ), c.tiers.map( ( t ) => [ t.tier_slug, money.format( t.amount ) ] ), money.format( c.buyups ) );
    // c.months → [ { month: '2026-07', amount_minor: null, amount: null }, { month: '2026-08', amount_minor: 1000, amount: 10 }, … ]
}

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →