Skip to main content

Add your add-on’s panel to the Analytics screen

Premium Advanced

When Analytics Dashboard is running on a show, its Analytics screen draws every panel in window.BenecasterExtensions.analyticsPanels after all of its own panels, with the screen’s current filters. Push your panel from your admin script; use ??= so it works whether your script or Analytics Dashboard’s loads first, and never assign the list.

  • props: showId (the show in Benecaster’s show switcher), scope ('show', or 'all' for every show where Analytics Dashboard is active; your route must apply the same per-show check), dateFrom / dateTo (UTC Y-m-d, inclusive), tierSlug (null for every tier; apply it only if it means something to your data).
  • order is optional, default 100, lower first; panels with the same order sort by id.
  • render runs as its own React component, so it may use hooks; fetch your own data there, sending X-WP-Nonce: window.benecasterAdmin.nonce.
  • The box and the heading (title) are drawn for you; return the body only.
  • An entry without a string id, a string title and a render function, or reusing an id, is skipped with a console warning. A panel that throws shows This panel could not be drawn. in its own box and leaves the screen working.
  • Nothing is drawn where Analytics Dashboard is not running on the show: Benecaster draws its own card there. To show your data without Analytics Dashboard, keep your own screen.

Code

const { React, i18n } = window.BenecasterExtensions; // Benecaster's shared runtime: never bundle your own React
const ext = ( window.BenecasterExtensions ??= {} );
( ext.analyticsPanels ??= [] ).push( {
    id: 'outlinks-clicks',                       // unique: prefix with your add-on
    title: i18n.__( 'Link clicks', 'benecaster-outlinks' ),
    order: 50,                                   // optional, default 100; lower first
    render: ( { showId, scope, dateFrom, dateTo, tierSlug } ) =>
        React.createElement( LinkClicks, { showId, scope, dateFrom, dateTo } ),
} );

View on GitHub →

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