I call the Analytics Reporting API V4 batchGet method with this code:
gapi.client.analyticsreporting.reports.batchGet( {
"reportRequests":[
{
"viewId":VIEW_ID,
"dateRanges":[
{
"startDate":"7daysAgo",
"endDate":"today"
}],
"metrics":[
{
"expression":"ga:pageviews" //correct answer
//"expression":"ga:pageviews,ga:users" //error!!
}],
"dimensions":[
{
"name":"ga:pageTitle"
}],
"orderBys":[
{
"fieldName": "ga:pageviews",
"sortOrder": "DESCENDING"
}]
}]
} ).then(function(response) {
console.log(response.result)
})
.then(null, function(err) {
// Log any errors.
console.log(err);
});
When using a single metric, the result is correct, but I need to query the API with two metrics and this is when the error happens. This message is logged in console:
message": "Invalid value 'ga:pageviews,ga:users' for metric parameter.
What is the correct way to do the query with two or more metrics? In the query explorer https://ga-dev-tools.appspot.com/query-explorer/ this kind of query are possible.
Thanks in advance.