Google-api-php-client: How to use quotaUser

Created on 9 Feb 2018  路  2Comments  路  Source: googleapis/google-api-php-client

Does this Client library allows setting Standard Query Parameter "quotaUser"?
Ref: https://developers.google.com/analytics/devguides/reporting/core/v4/parameters

It is important to be used when calling the API through CRON jobs on behalf of several users. https://developers.google.com/analytics/devguides/reporting/core/v3/limits-quotas

But I can't seem to figure out how to pass this query parameter. Should it be part of batchget call like this:
$optParams['quotaUser'] = "ABCXYZ123";
$analytics->reports->batchGet( $body, $optParams )

Or during initialize
$client->set... ?

question

Most helpful comment

It looks like a member of our great community answered your questions. Thanks Community! Please add a comment if you have any more questions and we can reopen this issue.

All 2 comments

Yes quota user should be working with this library.

$optParams['quotaUser'] = "ABCXYZ123";
$analytics->reports->batchGet( $body, $optParams )

Your code looks correct to me.

You haven't mentioned which quota error you are getting with this. However remember the quota with the Google Analytics API is based upon the view and not upon the user. Also due to the batching nature if you are sending more then one report you can easily hit a quota. If its coming from the same IP address going against the same view using a different quotaUser i dont think its going to help you.

It looks like a member of our great community answered your questions. Thanks Community! Please add a comment if you have any more questions and we can reopen this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artemiusgreat picture artemiusgreat  路  3Comments

usamamashkoor picture usamamashkoor  路  5Comments

camohub picture camohub  路  3Comments

ysaurabh33 picture ysaurabh33  路  3Comments

slaFFik picture slaFFik  路  5Comments