Google API会返回错误的值

时间:2015-01-08 18:15:40

标签: node.js google-analytics google-analytics-api

我想通过Analytics API按页面完成目标。日期是相同的,抽样是关闭的。

API:

{ kind: 'analytics#gaData',
  id: 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:90090243&dimensions=ga:hostname,+ga:pagePath&metrics=ga:users,ga:goalCompletionsAll,ga:goalValueAll&start-date=2015-01-05&end-date=2015-01-05',
  query: 
   { 'start-date': '2015-01-05',
     'end-date': '2015-01-05',
     ids: 'ga:90090243',
     dimensions: 'ga:hostname, ga:pagePath',
     metrics: [ 'ga:users', 'ga:goalCompletionsAll', 'ga:goalValueAll' ],
     'start-index': 1,
     'max-results': 1000,
     samplingLevel: 'HIGHER_PRECISION' },
  itemsPerPage: 1000,
  totalResults: 10,
  selfLink: 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:12345678&dimensions=ga:hostname,+ga:pagePath&metrics=ga:users,ga:goalCompletionsAll,ga:goalValueAll&start-date=2015-01-05&end-date=2015-01-05',
  profileInfo: 
   { profileId: '12345678',
     accountId: '12345678',
     webPropertyId: 'UA-12345678-1',
     internalWebPropertyId: '12345678',
     profileName: 'All Web Site Data',
     tableId: 'ga:90090243' },
  containsSampledData: false,
  columnHeaders: 
   [ { name: 'ga:hostname',
       columnType: 'DIMENSION',
       dataType: 'STRING' },
     { name: 'ga:pagePath',
       columnType: 'DIMENSION',
       dataType: 'STRING' },
     { name: 'ga:users', columnType: 'METRIC', dataType: 'INTEGER' },
     { name: 'ga:goalCompletionsAll',
       columnType: 'METRIC',
       dataType: 'INTEGER' },
     { name: 'ga:goalValueAll',
       columnType: 'METRIC',
       dataType: 'CURRENCY' } ],
  totalsForAllResults: 
   { 'ga:users': '155',
     'ga:goalCompletionsAll': '0',
     'ga:goalValueAll': '0.0' },
  rows: 
   [ [ 'mydomain.com', '/', '1', '0', '0.0' ],
     [ 'mydomain.com',
       '/brand-business-bundle',
       '1',
       '0',
       '0.0' ],
     [ 'mydomain.com',
       '/brand-business-internet',
       '1',
       '0',
       '0.0' ],
     [ 'mydomain.com', '/business-bundle', '1', '0', '0.0' ],
     [ 'mydomain.com',
       '/business-fiber-internet',
       '22',
       '0',
       '0.0' ],
     [ 'mydomain.com', '/business-internet', '37', '0', '0.0' ],
     [ 'mydomain.com', '/business-phone', '84', '0', '0.0' ],
     [ 'mydomain.com', '/privacy-policy', '1', '0', '0.0' ],
     [ 'mydomain.com',
       '/small-business-internet',
       '6',
       '0',
       '0.0' ],
     [ 'co.lumb.co', '/', '1', '0', '0.0' ] ] }

以下是我在Google Analytics信息中心中看到的内容:

Analytics goal values by page

我尝试过的事情:

  • 不同的采样水平(无效)
  • 从查询中删除其他维度(总计是正确的,但我想要每页数据)
  • 不同日期(无效)

为什么我在仪表板显示时从API返回如此低的值?

1 个答案:

答案 0 :(得分:0)

最令人迷惑的事情是,它工作了大约2个月并且突然破了。我怀疑在Analytics API中引入了一个错误。

解决方法是使用ga:goalCompletionLocation而不是ga:pagePath。我称之为解决方法而不是解决方案,因为就指标而言,你无法将ga:goalCompletionLocation与其他许多方法结合起来。