雖然指定日期範圍內的會話數遠小於500K limit,但我使用的是Google Analytics報告API,但我獲得了抽樣結果。我在一個月內只有〜4K會話。儘管會話數較少,Google Analytics採樣
我也設置「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屆,超過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']
打破請求到一個較小的日期範圍內沒有按小得多也沒有幫助。我試着用anti_sample = TRUE在R中使用GoogleAnalyticsR庫。
> 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]
當我檢查的自定義請求相同的數據,我看到類似的採樣
任何想法,爲什麼我得到的採樣結果,甚至認爲會話數超過限制少得多?
在谷歌的門票大約儘管低取樣會話我有一個類似的問題:自6月初通過PAGEPATH查詢totalEvents時,我只得到採樣結果。即使只要求一天!該物業沒有超過幾千場會議。但是這些匹配是由Measurement Protocol生成的。也許這就是原因。上個月我已經提取了正確的數據。 – JerryWho