developer-documentation
developer-documentation copied to clipboard
API pivotBy and pivotByColumn
https://github.com/matomo-org/matomo/issues/4776#issuecomment-65021172
What pivotBy-dimensions are available?
I can't seem to find any documentation about that. Neither is anything working, that I've tried to guess. I'm always getting the error Invalid dimension '<...>'..
Example: I want to pivot the VisitsSummary.getVisits by country.
https://<matomo-url>/?module=API
&method=VisitsSummary.getVisits
&idSite=2
&date=last7
&period=day
&format=xml
&language=de
&token_auth=<api-token>
&filter_limit=-1
&pivotBy=<??>
&pivotByColumn=Country
Have you checked https://developer.matomo.org/api-reference/reporting-api#optional-api-parameters docs?
Yes, I have. It just says:
[...]To pivot a report, this query parameter must be set to the ID of the dimension to pivot by. For example, queryParam=Referrers.Keyword would pivot against the Keyword dimension.
Sadly my question isn't answered by the docs.
I finally found them: All available dimensions can be requested with the method CustomReports.getAvailableDimensions
Imho this needs to be described in the Optional API parameters -> pivotBy; section.
It seems like that method possibly comes from a premium plugin that not all users may have available to them, can you confirm that you do use the Custom Reports premium plugin? Does it only apply then?
Oh yes it is, I wasn't aware of that (I asked a colleague).
pivotBy is only supported by custom reports and a couple of reports in core, that have a second dimension, like event reports. So this can't be used for all reports.