gpt4 book ai didi

java - Google Analytics API 数据范围提取限制问题

转载 作者:行者123 更新时间:2023-11-30 05:43:57 25 4
gpt4 key购买 nike

我正在尝试使用 Java 客户端库从 Google Analytics API 中提取一些维度和指标数据。

对于特定的 viewID,我发现从今天开始我无法提取超过 14 个月和 2 天的数据。我仅在使用 Java 客户端库和 API 以及某些特定 View 时遇到此问题。在 Google 界面中,我可以查看所有报告,没有 14 个月的限制。

这段Java代码:

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

我可以正常提取所有其他 View ,没有限制,但对于特定客户,发现了这个问题。

您对这个限制问题有什么想法吗?

我在 Java 中找不到有关这些限制的任何信息。

最佳答案

配额问题

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)

我很难知道您达到了哪个配额,因为您还没有发布消息。但是,如果您说它是单个 View ,那么我建议我这是 10000 个请求的数据配额,并且该 View 必须比您的其他 View 拥有更多的数据。您无法采取任何措施来延长此配额。您只能调整您的请求,以便发出更少的请求。

注意:Google 没有使用与您相同的客户端 ID,因此它们不受您的客户端限制的约束。如果您的客户端耗尽了配额,那么它就无法工作。这不会影响 Google Analytics 网站。

没有数据

如果请求返回零行,那么这不是配额问题,只是没有您请求的日期和元数据的数据。

我怀疑您使用的所有过滤器都存在问题。

仅使用 ga:date 维度和 ga:sessions 指标运行请求。不要添加过滤器。在 2010-01-01 - 2019-01-01 运行它,这应该可以帮助您找出数据开始记录的位置,或者您添加的所有过滤器是否存在问题。

关于java - Google Analytics API 数据范围提取限制问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55162878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com