Google Analytics(分析)API(每日综合浏览量)

时间:2018-12-03 01:36:44

标签: google-analytics

我正在Node应用程序中使用Analytics API,到目前为止,它具有以下功能:

const result = await google.analytics('v3').data.ga.get({ 'auth': jwt, 'ids': 'ga:' + viewId, 'start-date': '30daysAgo', 'end-date': 'today', 'metrics': 'ga:pageviews', });

返回:

... rows: [ [ '168' ] ] }

到目前为止效果很好!但是,我不希望获取总的浏览量,而是希望返回数据,以便可以查看每天的点击数,因为我想在应用程序中创建一个图表以使用图表库进行显示。朝正确方向的任何推动将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

这可以做到!

const result = await google.analytics('v3').data.ga.get({ 'auth': jwt, 'ids': 'ga:' + viewId, 'start-date': '30daysAgo', 'end-date': 'today', 'dimensions': 'ga:date', 'metrics': 'ga:pageviews', });

产生:

````

rows: [ [ '20181102', '0' ],
 [ '20181103', '2' ],
 [ '20181104', '0' ],
 [ '20181105', '0' ],
 [ '20181106', '2' ],
 [ '20181107', '12' ],
 [ '20181108', '10' ],
 [ '20181109', '11' ],
 [ '20181110', '7' ],
 [ '20181111', '20' ],
 [ '20181112', '6' ],
 [ '20181113', '16' ],
 [ '20181114', '8' ],
 [ '20181115', '8' ],
 [ '20181116', '4' ],
 [ '20181117', '9' ],
 [ '20181118', '2' ],
 [ '20181119', '2' ],
 [ '20181120', '7' ],
 [ '20181121', '4' ],
 [ '20181122', '3' ],
 [ '20181123', '3' ],
 [ '20181124', '4' ],
 [ '20181125', '0' ],
 [ '20181126', '3' ],
 [ '20181127', '6' ],
 [ '20181128', '2' ],
 [ '20181129', '3' ],
 [ '20181130', '0' ],
 [ '20181201', '6' ],
 [ '20181202', '9' ] ]