google-analytics - Google Analytics Reporting Api v4 报告请求响应具有行数但行元素为空

标签 google-analytics google-analytics-api google-analytics-firebase

我有 980 多个 viewid,我每天都在运行报告请求。它们正在加载到 rs db 中。

我让报告请求对所有 ID 执行初始 3 个月的回填运行。

在检查数据时,我们注意到一些 id 似乎没有为它们运行回填。我查看了日志,并没有从 api 收到任何类型的错误。

我开始为各个 viewid 运行单个报告请求,并在响应中返回行值。

我在发出请求的应用程序中添加了更多日志记录,因为我认为我可能只是没有发现错误。

对于第一个 850 左右,我得到了预期的结果。过去 3 个月的数据(如果有)。

最近 100 多个 id 我一直在收到对具有非 0 行数、最大值、最小值和总数以及空行元素的 viewid 的响应。这就是我现在陷入困境的地方。不确定这是 API 的错误还是功能。在任何地方都找不到任何先前提到的任何类似问题。

一些注意事项:

我们每天在一台服务器上同时运行 12 个报告请求。在 Api 控制台中,我们每天看到大约 12,000 个请求发出。它是一个发出请求的节点应用程序。在为所有 viewid 执行每日报告请求时,我们没有注意到这种情况,我们没有达到 50,000 个请求的每日限制,我们确实实现了指数回退,当我们遇到速率限制错误时,我们正在重试。

我们的报告请求之一示例:

`{
"reportRequests": [
{
"dateRanges": [
{
  "startDate": "2017-06-01",
   "endDate" : "2017-09-01"
}
],
"metrics": [
  {"expression": "ga:entrances"}, 
  {"expression": "ga:goalAbandonsAll"}, 
  {"expression": "ga:users"}, 
  {"expression": "ga:sessions"}, 
  {"expression": "ga:bounces"}, 
  {"expression": "ga:goalStartsAll"}, 
  {"expression": "ga:sessionDuration"}, 
  {"expression": "ga:goalValueAll"}, 
  {"expression": "ga:pageviews"}, 
  {"expression": "ga:timeOnPage"}
],
"pageSize": 10000, 
"includeEmptyRows": true, 
"dimensions": [
  {"name": "ga:adwordsCreativeID"},
  {"name": "ga:adSlot"},
  {"name": "ga:adTargetingType"},
  {"name": "ga:adDistributionNetwork"},
  {"name": "ga:adKeywordMatchType"},
  {"name": "ga:hour"},
  {"name": "ga:date"}
],
"samplingLevel": "LARGE",
"viewId": "123456789"
}
]
}`

我们看到奇怪的 react :
`{
"columnHeader":{
"dimensions":[
"ga:adwordsCreativeID",
"ga:adSlot",
"ga:adTargetingType",
"ga:adDistributionNetwork",
"ga:adKeywordMatchType",
"ga:hour",
"ga:date"
],
"metricHeader":{
"metricHeaderEntries":[
{"name":"ga:entrances","type":"INTEGER"},{"name":"ga:goalAbandonsAll","type":"INTEGER"},{"name":"ga:users","type":"INTEGER"},{"name":"ga:sessions","type":"INTEGER"},{"name":"ga:bounces","type":"INTEGER"},{"name":"ga:goalStartsAll","type":"INTEGER"},{"name":"ga:sessionDuration","type":"TIME"},{"name":"ga:goalValueAll","type":"CURRENCY"},{"name":"ga:pageviews","type":"INTEGER"},{"name":"ga:timeOnPage","type":"TIME"}
]
}},
"data":{
"totals":[
{"values":["1235","0","1245","1235","1091","0","63517.0","0.0","1450","63515.0"]}
],
"rowCount":602,
"minimums":[
{"values":["0","0","1","0","0","0","0.0","0.0","1","0.0"]}
],
"maximums":[
{"values":["10","0","10","10","8","0","4920.0","0.0","16","4909.0"]}
],
"rows":[]}`

最佳答案

您是否找到了有关此问题的更多信息?似乎如果您从 Google Analytics 得到“空”报告(仅包含最小值/最大值/总数)作为响应,发送新请求将解决问题。
检查 report['data]['rows'] 是识别报告是否为“空”的一种方法。

response = [...]
while self.is_response_empty(response):
    response = [...]

def is_response_empty(self, response):
    for report in response.get('reports', []):
        try:
            report['data']['rows']
            return False
        except:
            return True

关于google-analytics - Google Analytics Reporting Api v4 报告请求响应具有行数但行元素为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46098603/

相关文章:

google-analytics - GA Measurement Protocol:所有事件均显示为唯一

google-analytics - Google Analytics.js发送方法

google-analytics - 谷歌分析 : Moving Profile to Top-Level Account

android - 谷歌分析应用程序不向服务器发送数据

google-analytics - 您可以通过报告API获取 "Session Quality"吗?

google-analytics - 在GTM中,如何在Click Element触发器上使用CSS选择器?

java - 尝试实现 Google Analytics,错误跟踪器类无法解析为变量

google-app-engine - 使用 App Engine 开发服务器向 Google API 声明身份

objective-c - 在谷歌分析 API 中获取文章的创建日期

android - "An org admin has to sign the addendum before you can select the options Apps or Apps and web"|谷歌分析