Google Analytics Quota 2


Please Share

google-analytics

Google Analytics Quota

In this post we will be looking into the Google Analtyics Quota system.   We will be discussing why it is a good idea to use QuotaUser or UserIp in all of your calls to the Google Analytics API.    We will also be looking into exactly what the Quota system and why its even there.

Limits

The Google Analytics Quota system is there to keep you from spamming and overloading Google’s servers.   Lets face it we all know Google has a lot of servers,  but they don’t have an unlimited amount of servers.   We all want to know that when we use API the information we request will always be returns to you quickly and seamlessly.  The API wouldn’t be usable from a business standpoint if the servers were not stable because someone released an app that was slamming the servers constantly.   So Google had to set limit as to how much information each user / application can request for from the API each day.

Types of quotas

There are two types of quotas there is a quota that is associated with your application and there is the quota that is associated with a user using your application.       Lets use my Google Analtyics Import application as an example.  The application it self has a quota limit.  But each user that uses it to request data from Google Analtyics also has a quota.  I can request that the limit for my application be increased so that my application can have more users using it.  But you can not increase the quota limit on a single user.   There is a way around this i will explain it later.

The following is copied from Configuration and Reporting API Limits and Quotas directly from Google’s page.  You might want to check it in case any of the information below may have changed.   If it has changed please feel free to leave a comment and i will update this post asap.

General Quota Limits (All APIs)

The following quota limits are shared between the Management APICore Reporting APIMCF Reporting APIMetadata API, and Real Time Reporting API.

  • 50,000 requests per project per day – can be increased
  • 10 queries per second (QPS) per IP.
    • In the Developers Console this quota is referred to as the per-user limit. By default, it is set to 1 query per second (QPS) and can be adjusted to a maximum value of 10. If the per-user limit is set to a value larger than 10 QPS, the Google Analytics quota policy will still take effect and limit per-user requests to 10 QPS.
    • If your application makes all API requests from a single IP address (i.e. on behalf of your users) you should consider using the userIP or quotaUserparameters with each request to get full QPS quota for each user. See the query parameters summary for details.

As you can see the General limit per project is 50,000 requests.   Now what is a request.   Well if you request information from Google Analytics Core Reporting API (dimensions and metrics).
That’s one request  if that request happens to return more rows then the max-results you have set in the request then you get a next link.   When you use the next link that is also a request.     Now each user has a limit as well.   You can max send 10 requests (Queries) per seconds.  This is probably to keep you from flooding the server.     The default i believe is set to 3 queries per second you can set it up to 10 in your Google Apis Console for your app.

Each of the different APIs my have additional  quota limits.  For example the  Managment API limits how much data you can write, and upload each day there are also limits on Experiments.   I recommend you check Configuration and Reporting API Limits and Quotas  for any speciffic quoat limits you may face.

Errors 

If you go over your quota you will get an error back from Google.

403 dailyLimitExceeded Indicates that user has exceeded the daily quota (either per project or per profile). Do not retry without fixing the problem. You have used up your daily quota. See API Limits and Quotas.
403 usageLimits.userRateLimitExceededUnreg Indicates that the application needs to be registered in the Google Developers Console. Do not retry without fixing the problem. You need to register in Developers Console to get the full API quota.
403 userRateLimitExceeded Indicates that the user rate limit has been exceeded. The maximum rate limit is 10 qps per IP address. The default value set in Google Developers Console is 1 qps per IP address. You can increase this limit in the Google Developers Console to a maximum of 10 qps. Retry using exponential back-off. You need to slow down the rate at which you are sending the requests.
403 quotaExceeded Indicates that the 10 concurrent requests per profile in the Core Reporting API has been reached. Retry using exponential back-off. You need to wait for at least one in-progress request for this profile to complete.

QuotaUser and IPUser

Core Reporting API and Real Time Reporting API

These quotas are specific to the Core Reporting API and Real Time Reporting API:
•10,000 requests per profile per day
•10 concurrent requests per profile

When you send a request to Google Analytics each request you make to the service should include QuotaUser.    By adding QuotaUser you are telling Google this is a different user.   So if user ‘X’ sends 5000 requests to the server and user ‘Y’ sends 5050 neither one of them will go over the 10k user limit.   Now because the requests are profile i’m going to assume they mean view as long as two users arn’t sending the the same (ids) then it wont be a problem.

ManagementResource.AccountsResource.ListRequest AccountListRequest = service.Management.Accounts.List(); 
service.QuotaUser = "MyApplicationProductKey"; 
Accounts AccountList = AccountListRequest.Execute();

Now QuotaUser can be anything as long as you are sure its unique between your users.  This way each user will have there own I tend to use there email address.  You can if you are worried a user will go over there limit set a time-stamp on it as well this way you are sure if the user keeps sending requests they wont go over.    But you should be sure you know what you are doing this one user could blow out your 50k app limit by spamming the server.

Conclusion

I hope this little post has shed some light on the Quota system used with Google Analytics.  You should know understand which of the limits apply to each of the different API’s .  You should also be aware of how to ensure that your users arent all bunched in under the same quotaUser and understand why using QuotaUser in all of your Google Analtyics API calls.

 

Please Share


Linda Lawton

About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as a developer and a database expert. I have been working with several of the Google APIs, since 2012. I helping others in the On-Line community to develop with the Google APIs, by creating my own blog www.daimto.com. This and my presence on a number of On-Line developer forums lead me to be noticed by the Google Analytics API development team. I was nominated for and recently became one of the first Google Developer Experts for Google Analytics.


Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Google Analytics Quota

  • Patrick Hommers

    Hello,

    thank you for your very much for your explanations. I have problems with the “403 userRateLimitExceeded” error. I make some parallel request to the analytics core api and for each request I change my quotaUser ID. But I still get this error. Can you help me? Whats wrong with my code? I am using the lib Google.Apis.Analytics.v3;

    Here is my service initialization:

    private AnalyticsService AuthenticateServiceAccount(string applicationName, string serviceAccountEmail, string keyFilePath)
    {
    // check the file exists
    if (!File.Exists(keyFilePath))
    {
    logger.Error(“Could not find keyfile for Google Service”);
    throw new FileNotFoundException(“Could not find keyfile”);
    }

    string[] scopes = new string[] { AnalyticsService.Scope.Analytics, // view and manage your analytics data
    AnalyticsService.Scope.AnalyticsEdit, // edit management actives
    AnalyticsService.Scope.AnalyticsManageUsers, // manage users
    AnalyticsService.Scope.AnalyticsReadonly}; // View analytics data

    var certificate = new X509Certificate2(keyFilePath, “notasecret”, X509KeyStorageFlags.Exportable);
    try
    {
    ServiceAccountCredential credential = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
    Scopes = scopes
    }.FromCertificate(certificate));

    // Create the service.
    AnalyticsService service = new AnalyticsService(new BaseClientService.Initializer()
    {
    HttpClientInitializer = credential,
    ApplicationName = applicationName,
    DefaultExponentialBackOffPolicy = Google.Apis.Http.ExponentialBackOffPolicy.Exception | Google.Apis.Http.ExponentialBackOffPolicy.UnsuccessfulResponse503
    });

    return service;
    }

    And my request:

    try
    {

    DataResource.GaResource.GetRequest request = service.Data.Ga.Get(profile, startDate, endDate, metrics);

    service.QuotaUser = randomStringGeneration; //40 character long string

    service.MaxResults = maxResults;
    service.Sort = sort;
    service.StartIndex = 1;
    service.Filters = filterString;
    serviceDimensions = dimensions;

    GaData data = service.Execute();

    • Linda Lawton
      Linda Lawton Post author

      I will have to contact the Devs but I would have to suspect that a service account is just one user and Google knows that. Even if you change quotaUser it doesn’t always work

      “403 userRateLimitExceeded” is basically flood protection on Googles part they want to make sure that one person doesn’t sit and hammer there granted extensive servers. The only thing you can do is add a sleep and slow down your application a little.