2017-06-04 49 views
0

雖然指定日期範圍內的會話數遠小於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] 

當我檢查的自定義請求相同的數據,我看到類似的採樣

Custom report snapshot

任何想法,爲什麼我得到的採樣結果,甚至認爲會話數超過限制少得多?

+0

在谷歌的門票大約儘管低取樣會話我有一個類似的問題:自6月初通過PAGEPATH查詢totalEvents時,我只得到採樣結果。即使只要求一天!該物業沒有超過幾千場會議。但是這些匹配是由Measurement Protocol生成的。也許這就是原因。上個月我已經提取了正確的數據。 – JerryWho

回答

0

500K的適用於默認報告

編輯:在您正在使用的即席查詢的日期範圍內的財產水平 500K會議。

默認報告解釋說:

Analytics(分析)有一組在左窗格中下觀衆,獲取,行爲和轉化上市的預配置,默認報告。

看起來您正在使用具有次級維度的臨時報告,因此500k閾值可能不再適用,並且可能低得多。在您最初鏈接到here的頁面中,有關於此的更多信息。

+2

默認報告完全沒有采樣,因爲它們是預先彙總的。取樣僅適用於臨時報告(定製報告,當您添加次要尺寸或片段時) – Eduardo

+0

是的,您是正確的。我誤解了文檔。 – etemple1

0

您在該視圖中只有4k個會話......但也許該視圖使用的是過濾器...通過查看沒有過濾器的視圖,檢查您在該媒體資源中擁有多少流量...... 500k場會議在屬性級別不在視圖級別。

相關問題