Search code examples
javagoogle-apigoogle-analytics-apigoogle-api-java-clientquota

Google Analytics API limit of Data range extraction issue


I'm trying to extract some dimensions and metrics data from Google Analytics API using the Java client library.

For a specific viewID I see that I cannot extract more than 14 months & 2 days of data starting from today. I am faced this problem only with the Java client library and the API and for some specific views. In the Google interface I can see all reports without the 14 months limits.

This Java code :

DateRange dateRange = new DateRange().setStartDate(startDate).setEndDate(endDate);

    DimensionFilter dimensionFilter = new DimensionFilter();
    dimensionFilter.setDimensionName("ga:medium");
    dimensionFilter.setOperator("EXACT");
    dimensionFilter.setExpressions(Collections.singletonList("organic"));
    DimensionFilterClause dimensionFilterClause = new DimensionFilterClause();
    dimensionFilterClause.setFilters(Collections.singletonList(dimensionFilter));

    MetricFilter metricFilter = new MetricFilter();
    metricFilter.setMetricName("ga:sessions");
    metricFilter.setNot(true);
    metricFilter.setComparisonValue("0");
    MetricFilterClause metricFilterClause = new MetricFilterClause();
    metricFilterClause.setFilters(Collections.singletonList(metricFilter));

    ReportRequest reportRequest = new ReportRequest()
            .setViewId(viewID)
            .setDateRanges(Collections.singletonList(dateRange))
            .setSamplingLevel(samplinglevel.name())
            .setPageSize(100000)
            .setDimensionFilterClauses(Collections.singletonList(dimensionFilterClause))
            .setMetricFilterClauses(Collections.singletonList(metricFilterClause))
            .setDimensions(dimensionList)
            .setMetrics(metricList)
            .setIncludeEmptyRows(false);

I can extract normally all others views without a limit, but for a specific client a found this problem.

Do you have any idea about this limits issue ?

I can't find any information on these limit in Java.


Solution

  • Quota Issue

    there are a number of quotas for the Google Analytics api. Limits and Quotas

    General quota limits

    • 50,000 requests per project per day, which can be increased.
    • 10 queries per second (QPS) per IP address. In the API Console, there is a similar quota referred to as Requests per 100 seconds per user. By default, it is set to 100 requests per 100 seconds per user and can be adjusted to a maximum value of 1,000. But the number of requests to the API is restricted to a maximum of 10 requests per second per user.
    • If your application makes all API requests from a single IP address (i.e., on behalf of your users), use the userIP or quotaUser parameter with each request to get full QPS quota for each user. See the standard query parameters summary for details.

    Reporting APIs

    The following quotas apply to all Reporting APIs, including the Core Reporting API v3, Analytics Reporting API v4, Real Time API v3, and Multi-channel Funnel API v3:

    • 10,000 requests per view (profile) per day (cannot be increased)
    • 10 concurrent requests per view (profile) (cannot be increased)

    Its hard for me to know which quota you are hitting as you have not posted the message. However if you are saying its a single view then i would suggest to me that it is the 10000 requests a data quota and that this view must have more data than your other views. There is nothing you can do to extend this quota. You can only tune your requests so that you make fewer requests.

    Note: google is not using the same client id as you are so they are not bound by the limits that your client is. If your client runs itself out of quota then its not going to work. This will not effect the google analytics website.

    NO DATA

    If a request returns zero rows then this is not a quota issue there is simply no data for the dates and metadata you are requesting.

    I would suspect there is an issue with all those filters you are using.

    Run a request with just ga:date dimension and the ga:sessions metric. Dont add your filters. Run it for 2010-01-01 - 2019-01-01 this should help you find out where the data started being recorded or if its an issue with all those filters you have added.