Analytics Core Reporting API。不同段中的行具有相同的值

时间:2016-07-19 12:18:22

标签: google-analytics google-reporting-api

我可能有一些误解,所以需要帮助来理解究竟是什么错误。

在analytics.google.com我有两个段,它们因事件标签而异,但都来自同一个事件。在分析界面中,段之间的差异是可见的: analytics.google.com interface screenshot

当我尝试使用查询资源管理器等工具获取相同数据时,结果也不同: ga-dev-tools.appspot.com/query-explorer/ interface screenshot

但是,当我使用报告API v4获取此数据时,段之间的所有值都相同。我也尝试过使用API​​ v3,这导致了类似的结果。

这是我的代码:

googleapis.analyticsreporting('v4').reports.batchGet({
  'headers': {'Content-Type': 'application/json'},
  "auth": oauth2Client,
  "resource":{
    reportRequests:[
      {
        "viewId": "ga:"+Meteor.settings.admin.googleAPI.viewID,
        "dateRanges":[{
          "startDate": '2016-07-01',
          "endDate": moment().format('YYYY-MM-DD'),
        }],
        "metrics": [{"expression":"ga:pageviews"},{"expression":"ga:avgtimeonpage"}],
        "dimensions": [{"name":"ga:pagepath"},{"name":"ga:segment"}],
        "segments": [{
          "dynamicSegment":
            {
              "name": "version_bw",
              "userSegment":
                {
                  "segmentFilters": [
                    {
                      "simpleSegment":
                        {
                          "orFiltersForSegment": [
                          {
                          "segmentFilterClauses": [
                            {
                            "dimensionFilter":
                              {
                                "dimensionName": "ga:eventAction",
                                "operator": "EXACT",
                                "expressions": ["set-visual-code"]
                              }
                            },{
                            "dimensionFilter":
                              {
                                "dimensionName": "ga:eventLabel",
                                "operator": "EXACT",
                                "expressions": ["bw"]
                              }
                            }
                          ]
                        }]
                      }
                  }]
                }
          }
        },{
          "dynamicSegment":
            {
              "name": "version_color",
              "userSegment":
                {
                  "segmentFilters": [
                    {
                      "simpleSegment":
                        {
                        "orFiltersForSegment": [
                          {
                          "segmentFilterClauses": [
                            {
                            "dimensionFilter":
                              {
                                "dimensionName": "ga:eventAction",
                                "operator": "EXACT",
                                "expressions": ["set-visual-code"]
                              }
                            },{
                            "dimensionFilter":
                              {
                                "dimensionName": "ga:eventLabel",
                                "operator": "EXACT",
                                "expressions": ["color"]
                              }
                            }
                          ]
                        }]
                      }
                  }]
                }
          }
        }]
      }
    ]
  }

}, function(err, response) {
  if (err) {
    console.log('API Error: '+ err);
    return;
  }
  var rows = response.reports[0].data.rows;
  for (var i = 0; i < rows.length; i++) {
    console.log(rows[i].dimensions);
    console.log(rows[i].metrics);
  }
});

导致以下输出结果:

I20160719-14:09:10.405(2)? [ '/', 'version_bw' ]
I20160719-14:09:10.406(2)? [ { values: [ '373', '174.11977715877438' ] } ]
I20160719-14:09:10.406(2)? [ '/', 'version_color' ]
I20160719-14:09:10.407(2)? [ { values: [ '373', '174.11977715877438' ] } ]
I20160719-14:09:10.407(2)? [ '/portfolio', 'version_bw' ]
I20160719-14:09:10.407(2)? [ { values: [ '468', '126.2876404494382' ] } ]
I20160719-14:09:10.407(2)? [ '/portfolio', 'version_color' ]
I20160719-14:09:10.408(2)? [ { values: [ '468', '126.2876404494382' ] } ]
I20160719-14:09:10.408(2)? [ '/portfolio/', 'version_bw' ]
I20160719-14:09:10.409(2)? [ { values: [ '22', '229.54545454545453' ] } ]
I20160719-14:09:10.410(2)? [ '/portfolio/', 'version_color' ]
I20160719-14:09:10.410(2)? [ { values: [ '22', '229.54545454545453' ] } ]
I20160719-14:09:10.410(2)? [ '/portfolio/graphics', 'version_bw' ]
I20160719-14:09:10.410(2)? [ { values: [ '84', '60.073170731707314' ] } ]
I20160719-14:09:10.410(2)? [ '/portfolio/graphics', 'version_color' ]
I20160719-14:09:10.410(2)? [ { values: [ '84', '60.073170731707314' ] } ]
I20160719-14:09:10.411(2)? [ '/portfolio/graphics/some-graphic', 'version_bw' ]
I20160719-14:09:10.411(2)? [ { values: [ '134', '42.02290076335878' ] } ]
I20160719-14:09:10.411(2)? [ '/portfolio/graphics/some-graphic', 'version_color' ]
I20160719-14:09:10.411(2)? [ { values: [ '134', '42.02290076335878' ] } ]

0 个答案:

没有答案