2017-02-13 43 views
0

谷歌Analytics(分析)API,我能夠使用RGA library.Sharing查詢MCF API接收數據:錯誤而獲取數據從來自R

temp_data <- get_mcf(profileId = "xxxxxxxxx", start.date = "2017-01-09", 
    end.date = "2017-01-31", metrics = "mcf:totalConversions", 
    dimensions = "mcf:sourceMediumPath", sort = NULL, 
    filters = "mcf:conversionType==Transaction", 
    samplingLevel = NULL,start.index=1,max.results = 100000) 

上面的查詢獲取我的14836行數據。當我試圖增加數據範圍時,我得到這個錯誤。 錯誤:服務器錯誤:(500)內部服務器錯誤 響應太大:內部錯誤

是否有任何解決方法?

+0

增加數據範圍或日期範圍? – dikesh

+0

增加日期範圍會增加數據 –

回答

0

如果選中文檔中的MCF API,你會發現,對於最大結果的有效值是1000到10000之間的數字

max-results

max-results=100 Optional. Maximum number of rows to include in this response. You can use this in combination with start-index to retrieve a subset of elements, or use it alone to restrict the number of returned elements, starting with the first. If max-results is not supplied, the query returns the default maximum of 1000 rows.

The Multi-Channel Funnels Reporting API returns a maximum of 10,000 rows per request, no matter how many you ask for. It can also return fewer rows than requested, if there aren't as many dimension segments as you expect. For instance, there are fewer than 300 possible values for mcf:medium, so when segmenting only by medium, you can't get more than 300 rows, even if you set max-results to a higher value.

你應該以取回下使用nextLink如果您的回覆中有多於10000行的數據集。

更新:出於好奇,我聯繫了Google AnalyticsAPI團隊。我覺得很奇怪,你得到更多的行,那麼你應該基於文檔。這是我回復的迴應

To me it sounds like the developer needs to just shorten the date range to not get 500 server timeout. I don't know how he knows how many row's a query will return when he is getting a 500 response so I think there is a bit of confusion in his question still. As far as I know we have not changed the number of rows allowed in the response, but we still need to construct the full response on our side and sort, so if the number of rows is large and the CPU usage on the server is heavy during his request he will easily get a 500 timeout error.

That being said I have asked the Backend team if anything has changed about the 10k limit recently..

- google dev who shall not be named -

+0

感謝您的回覆。 如上所述,此代碼一次性使用批處理獲取14386行數據。因此,我認爲這不是每個請求的限制問題,可以從API –

+0

檢查更新我認爲這很奇怪你說你收到的行數,所以我在這裏聯繫谷歌是答覆。 – DaImTo

+0

是的,我知道我們有10000行的限制,但在這種情況下,我使用了RGA包中包含的自動分頁功能。通過組合多個數據請求,自動分頁返回10,000行以上的結果。我已經提到這個文件的相同:https://cran.r-project.org/web/packages/RGA/RGA.pdf。 –