Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New processed metric metadata: processed metric formula #21937

Open
diosmosis opened this issue Feb 13, 2024 · 1 comment
Open

New processed metric metadata: processed metric formula #21937

diosmosis opened this issue Feb 13, 2024 · 1 comment
Labels
c: APIs For bugs and features in the Matomo HTTP and plugin APIs. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@diosmosis
Copy link
Member

diosmosis commented Feb 13, 2024

Summary

Refs matomo-org/looker-studio-connector#3
Refs matomo-org/looker-studio-connector#29
Refs #21936

In order for Looker Studio to further group processed metric data in reports after they are requested from Matomo, Looker Studio needs to know the formula used to compute these metrics. For example, bounce_rate is computed as bounce_count / nb_visits. Giving this formula to Looker Studio will allow it to aggregate different bounce_rates together.

Exposing this information via Matomo's metadata API will allow the connector to forward this information to Looker Studio.

Formula should provide the unformatted values, and, ideally, it should be possible to express these formulae via Looker Studio arithmetic/functions supported by Looker Studio (https://support.google.com/looker-studio/table/6379764).

Example API output:

<metadata>
    <processedMetricFormula>
        <bounce_rate>bounce_count / nb_visits</bounce_rate>
        <avg_time_on_page>sum_time_spent / nb_hits</avg_time_on_page>
    </processedMetricFormula>
</metadata>
@diosmosis diosmosis added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. To Triage An issue awaiting triage by a Matomo core team member labels Feb 13, 2024
@michalkleiner michalkleiner added c: APIs For bugs and features in the Matomo HTTP and plugin APIs. and removed To Triage An issue awaiting triage by a Matomo core team member labels Feb 13, 2024
@michalkleiner michalkleiner added this to the For Prioritization milestone Feb 13, 2024
@diosmosis
Copy link
Member Author

Been looking into this, and for some processed/computed metrics, this is simple to add (ie, BounceRate, etc.). Some processed metrics contain complex logic that can't (and shouldn't) be expressed as formula metadata, like https://github.com/matomo-org/matomo/blob/5.x-dev/plugins/Goals/Columns/Metrics/RevenuePerVisit.php.

To be able to properly add this metadata, in a way that allows the new metadata to be easily maintained (ie, kept in sync with the actual code), it would likely be necessary to change how ProcessedMetrics work, reducing their responsibility. Instead of allowing arbitrary logic, they would need to be limited to simple operations, and the temporary metrics they use would have to be directly available as other column values.

So processed metrics like EvolutionMetric would need to have the past data included in the result DataTable, as opposed to in another DataTable. And RevenuePerVisit would need the goals array metric to be flattened. Given this would be a significant change, it's probably better the core team handle it, after deciding on what their solution would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: APIs For bugs and features in the Matomo HTTP and plugin APIs. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

2 participants