developer-documentation icon indicating copy to clipboard operation
developer-documentation copied to clipboard

API pivotBy and pivotByColumn

Open meyerdominik opened this issue 1 year ago • 6 comments

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

meyerdominik avatar Jan 25 '24 08:01 meyerdominik

Have you checked https://developer.matomo.org/api-reference/reporting-api#optional-api-parameters docs?

michalkleiner avatar Jan 25 '24 08:01 michalkleiner

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.

meyerdominik avatar Jan 25 '24 11:01 meyerdominik

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.

meyerdominik avatar Feb 16 '24 06:02 meyerdominik

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?

michalkleiner avatar Mar 13 '24 09:03 michalkleiner

Oh yes it is, I wasn't aware of that (I asked a colleague).

meyerdominik avatar Mar 15 '24 08:03 meyerdominik

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.

sgiehl avatar Mar 25 '24 16:03 sgiehl