javascript – 在Google AnalyticsAPI中使用和查询自定义维度

前端之家收集整理的这篇文章主要介绍了javascript – 在Google AnalyticsAPI中使用和查询自定义维度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试查询我的Analytics(通用)以接收按自定义维度排序的指标列表.

7月,Google Analytics API blog宣布:

“Developers can use custom dimensions to send unique IDs into Google Analytics,and then use the core reporting API to retrieve these IDs along with other Google Analytics data.

For example,your content management system can pass a content ID as a custom dimension using the Google Analytics tracking code. Developers can then use the API to get a list of the most popular content by ID and display the list of most popular content on their website.

尽管如此,我仍无法从我的Google Analytics中检索任何结果.我的发送功能如下:

ga('send','pageview',{
  'dimension1':'red'
});

不幸的是,使用’ga:dimension1 == red’过滤器查询GA不会检索任何结果.

gapi.client.analytics.data.ga.get({
  'ids': 'ga:' + "123456",'start-date': '2013-11-10','end-date': '2013-11-20','metrics': 'ga:visits','filters': 'ga:dimension1==red'
}).execute(function(r){console.log(r);});

我也尝试使用自定义段来检索数据,但无济于事:

'segment': 'dynamic::ga:dimension1==red'

数据显示在GA的自定义报告中.如何通过API访问它?

解决方法

您需要在查询中包含维度.例如’dimension’:’ga:dimension1′,然后使用你的过滤器’ga:dimension1 == red’. Query Explorer对测试API请求非常有帮助.
原文链接:https://www.f2er.com/js/149994.html

猜你在找的JavaScript相关文章