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.
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)
- 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
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.
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.
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.