Adding metrics in plugin

Hello!

I am creating a plugin to track metrics related to media streaming (eg. play_time, session_id, streaming_protocol) and to generate a simple report taking these metrics into account (eg. consolidating connection count by session_id).

I am taking inspiration from the bandwidth plugin which I also require in order to track bandwidth.

My question is:
Should I add my new metrics the same way the bandwidth plugin does or should I use custom dimensions?

The bandwidth plugin defines its new metrics with this code:

class Metrics
{

    const METRICS_PAGE_SUM_BANDWIDTH = 1090;
    const METRICS_PAGE_MIN_BANDWIDTH = 1091;
    const METRICS_PAGE_MAX_BANDWIDTH = 1092;
    const METRICS_NB_HITS_WITH_BANDWIDTH = 1093;

    const COLUMN_TOTAL_OVERALL_BANDWIDTH  = 'nb_total_overall_bandwidth';
    const COLUMN_TOTAL_PAGEVIEW_BANDWIDTH = 'nb_total_pageview_bandwidth';
    const COLUMN_TOTAL_DOWNLOAD_BANDWIDTH = 'nb_total_download_bandwidth';
    [...]

If I go the same way as the Bandwidth plugin, how I can choose the index numbers so that they do not collide with any other metric?

If I go the way of the custom dimensions, how can I pick the ID of the custom dimension and how do I tell for which website it should be present?

Thank you,
Andrea

Looks like I have understood better the difference between dimensions created by a plugin and custom dimensions created through the admin interface. For one, dimensions created by a plugin can have any name and not only “dimensions” + dimension_id

Still figuring out how metrics work and how metric ID collisions are handled

Hello @rivoduck

We created a awesome Media Analytics plugin: https://plugins.piwik.org/MediaAnalytics - maybe this would be a suitable solution for you?