Reputation: 133
There are several metrics and dimensions - let it be a list.
For example:
Year dimension and New Session measure.
How to get a list of available metrics and dimensions for this list via Google Analytics API java SDK V3 so that the error does not fall
"Selected dimensions and metrics cannot be queried together"?
Upvotes: 2
Views: 5358
Reputation: 133
Sulution: take json from here https://ga-dev-tools.appspot.com/ga_cubes.json - this is a list of cubes. For each cube it contains the set of dimensions and metrics that it consists of.
The algorithm is as follows: We run through the List (for example Year dimension and New Session measure), and look if at least one of these cubes has all the dimensions and metrics from the list, then such metrics and dimensions are compatible, otherwise not.
So it works in https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/
However, it is worth considering that some metrics work together only when there is an additional dimension. For example: ga:14dayUsers, ga:newUsers works only with days dimension.
Upvotes: 0
Reputation: 117301
How to get a list of available metrics and dimensions for this list via Google Analytics API .
The first thing you need to understand is that the Google Analytics Core reporting API and the Google Analytics reporting APIs. Only return the data from within Google analytics. Neither has the power to return to you a list of dimensions and metrics.
To get a list of Dimensions and metrics that can be used in these APIs you should look at the Meta data api . It returns a list of all the dimensions and metrics that can be used with the Google Analytics APIs to query Google analytics data.
GET https://www.googleapis.com/analytics/v3/metadata/ga/columns
"Selected dimensions and metrics cannot be queried together"?
Message means that some metrics and dimensions just cant be queried together because there isnt the proper data relation between them. There is no api that will tell you which dimensions and metrics can be queried together.
You have two options:
Upvotes: 5