Reputation: 23
In docs for Google Analytics API Response body contains queryCost
and resourceQuotasRemaining
. But, when I do
curl -i -H 'Content-Type: application/json' -X POST 'https://analyticsreporting.googleapis.com/v4/reports:batchGet?access_token=mytoken' -d '{"reportRequests":[{"viewId":"ga:myviewId","dateRanges":[{"startDate":"2019-12-04","endDate":"2019-12-04"}],"dimensions":[{"name":"ga:campaign"},{"name":"ga:adContent"},{"name":"ga:keyword"},{"name":"ga:currencyCode"}],"dimensionFilterClauses":[{"filters":[{"dimensionName":"ga:sourceMedium","operator":"EXACT","expressions":["Yandex.Market / cpc"]}]},{"filters":[{"dimensionName":"ga:campaign","operator":"PARTIAL","expressions":["msk"]}]}],"metrics":[{"expression":"ga:goal12Completions"}],"metricFilterClauses":[{"filters":[{"metricName":"ga:goal12Completions","operator":"GREATER_THAN","comparisonValue":"0"}]}],"hideTotals":true,"hideValueRanges":true}]}'
response body do not contain queryCost
and resourceQuotasRemaining
{"reports":[{"columnHeader":{"dimensions":[...],"metricHeader":{"metricHeaderEntries":[...]}},"data":{"rows":[{"dimensions":[...],"metrics":[...]}],"rowCount":1,"isDataGolden":true}}]}
If I add to JSON in POST "useResourceQuotas":true
, I get error: "The request is not eligible for resource quotas. Check if account is premium and whitelisted." (code 400).
How I can get information about query cost, quotas remaining and other limit stats using API? Or it is possible only for premium accounts?
Upvotes: 0
Views: 551
Reputation: 584
Pete,
Resource based quota feature is only available to Analytics 360 users.
Thanks, Ilya
Upvotes: 2
Reputation: 116986
your request doesn't include useResourceQuotas = true. its default false
{
"reportRequests": [
{
"viewId": "ga:xxxx",
"dateRanges": [
{
"startDate": "2019-12-04",
"endDate": "2019-12-04"
}
],
"metrics": [
{
"expression": "ga:users"
}
],
"hideTotals": true,
"hideValueRanges": true
}
],
"useResourceQuotas": true
}
Result
{
"reports": [
{
"columnHeader": {
"metricHeader": {
"metricHeaderEntries": [
{
"name": "ga:users",
"type": "INTEGER"
}
]
}
},
"data": {
"rows": [
{
"metrics": [
{
"values": [
"1298"
]
}
]
}
],
"rowCount": 1,
"isDataGolden": true
}
}
],
"resourceQuotasRemaining": {
"dailyQuotaTokensRemaining": 100000,
"hourlyQuotaTokensRemaining": 25000
}
}
Doesn't work with every request. I would suggest that you go though yours adding different things to see what the exact problem is. Start by removing all those filters. Once you figure out exactly which one is giving you the error with the userREsourceQuotas let me know and i will ping the team about having the documentation updated. It doesnt say currently that there should be an issue with using it with anything. I cant test your request I dont have any accounts with goals setup like that that i could test with.
Upvotes: 0