Custom Metrics

I am looking for what you might see as the equivalent of custom metrics in GA. The custom variables in Piwik seem more akin to custom dimensions in GA. But I would need an additional field (which would only be integers) that could be summed/averaged/other simple math function on a list of numbers.

An offhand example would be tracking the size of a download the user has completed on a page visit. And I would like to query the total size that user has downloaded. Is that possible with Piwik?

Also I would only be using the core Tracking/Reporting API themselves. I’ve looked over them, but didn’t notice anything similar to what I’m talking about.

I am looking for the same answer to this question.

I am also looking for this feature to track data from an offline API.
I think this feature is an enhancement corcerning Calculated metrics: generate custom metrics values · Issue #12390 · matomo-org/matomo · GitHub