gpt4 book ai didi

google-analytics - 尽管 session 数较少,但 Google Analytics(分析)抽样

转载 作者:行者123 更新时间:2023-12-03 17:33:55 27 4
gpt4 key购买 nike

我正在使用 Google Analytics Reporting API,但即使指定日期范围内的 session 远少于 500K limit,我也会得到抽样结果。 .我一个月只有约 4K 次 session 。

我还将“samplingLevel”设置为“LARGE”。

这是 Python 查询:

    response=analytics.reports().batchGet(
body={
"reportRequests":[
{
"viewId":myViewID,
"dateRanges":[
{
"startDate":"2017-05-01",
"endDate":"2017-05-30"
}],
"samplingLevel":"LARGE",
"metrics":[
{
"expression":"ga:sessions"
}],
"dimensions": [
{
"name":"ga:browser"

},
{
"name":"ga:city",
}
]
}]
}
).execute()

正如您在下面看到的示例空间是 4365 个 session ,远小于 500K 的限制
response.get('reports', [])[0].get('data',[]).get('samplesReadCounts',[])
Out[31]: [u'2051']

response.get('reports', [])[0].get('data',[]).get('samplingSpaceSizes',[])
Out[32]: [u'4365']

将请求分解为较小的日期范围也无济于事。我使用 R 中的 GoogleAnalyticsR 库和 anti_sample=TRUE 进行了尝试。
    > web_data <- google_analytics_4(view_id, 
+ date_range = c("2017-05-01", "2017-05-30"),
+ dimensions = c("city","browser"),
+ metrics = c("hits"),
+ samplingLevel="LARGE",
+ anti_sample = TRUE)
2017-06-04 11:54:51> anti_sample set to TRUE. Mitigating sampling via multiple API calls.
2017-06-04 11:54:51> Finding how much sampling in data request...
2017-06-04 11:54:52> Downloaded [10] rows from a total of [15].
2017-06-04 11:54:52> Data is sampled, based on 47% of sessions.
2017-06-04 11:54:52> Finding number of sessions for anti-sample calculations...
2017-06-04 11:54:53> Downloaded [30] rows from a total of [30].
2017-06-04 11:54:53> Calculated [3] batches are needed to download approx. [18] rows unsampled.
2017-06-04 11:54:53> Anti-sample call covering 14 days: 2017-05-01, 2017-05-14
2017-06-04 11:54:54> Downloaded [7] rows from a total of [7].
2017-06-04 11:54:54> Data is sampled, based on 53.2% of sessions.
2017-06-04 11:54:54> Anti-sampling failed
2017-06-04 11:54:54> Anti-sample call covering 9 days: 2017-05-15, 2017-05-23
2017-06-04 11:54:54> Downloaded [4] rows from a total of [4].
2017-06-04 11:54:54> Data is sampled, based on 55.7% of sessions.
2017-06-04 11:54:54> Anti-sampling failed
2017-06-04 11:54:54> Anti-sample call covering 7 days: 2017-05-24, 2017-05-30
2017-06-04 11:54:55> Downloaded [10] rows from a total of [10].
2017-06-04 11:54:55> Data is sampled, based on 52.3% of sessions.
2017-06-04 11:54:55> Anti-sampling failed
Joining, by = c("city", "browser")
Joining, by = c("city", "browser")
2017-06-04 11:54:55> Finished unsampled data request, total rows [13]

当我在自定义请求中检查相同的数据时,我看到了类似的采样

Custom report snapshot

知道为什么即使 session 计数远低于限制,我也会得到采样结果?

最佳答案

尽管 https://issuetracker.google.com/issues/62525952 的 session 数很少,但 Google 有一张关于采样的罚单

关于google-analytics - 尽管 session 数较少,但 Google Analytics(分析)抽样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44352148/

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