使用和查询谷歌Analytics(分析)API定义维度 [英] Using and querying Custom Dimensions in Google Analytics API

查看:333
本文介绍了使用和查询谷歌Analytics(分析)API定义维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图查询我的分析(通用),以接收自定义维度分类指标的清单。

I am attempting to query my Analytics (Universal) to receive a list of metrics sorted by a custom dimension.

在七月,谷歌Analytics(分析)API博客宣布:

开发人员可以使用自定义尺寸发送唯一的ID到谷歌Analytics(分析),然后使用核心API报告与其他谷歌Analytics(分析)数据一起检索这些标识。

"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.

例如,内容管理系统可以通过一个内容ID作为使用谷歌Analytics跟踪code自定义维度。 开发者可以再使用API​​来获取由ID最受欢迎的内容列表,并显示在其网站上最受欢迎的内容列表。

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."

尽管如此,我已经无法从我的分析检索不到任何结果。我的发送功能如下:

Despite this, I have been unable to retrieve any results from my Analytics. My send function is below:

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

不幸的是,使用的过滤器查询GAGA:DIMENSION1 ==红'。不检索任何结果。

Unfortunately, querying GA using a filter of 'ga:dimension1 == red' does not retrieve any results.

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);});

我也尝试使用自定义细分检索数据,但没有成功:

I have also tried using custom segments to retrieve the data, to no avail:

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

数据显示在GA自定义报表。我怎样才能通过API访问它?

The data appears in Custom Reports in GA. How can I access it via the API?

推荐答案

您需要包括在查询中的维度。如'尺寸':'嘎:DIMENSION1 ,然后用你的过滤器GA:DIMENSION1 ==红色的 。该查询浏览是用于测试的API请求非常有用的。

You need to include a the dimension in the query. Such as 'dimension': 'ga:dimension1', then use your filter 'ga:dimension1==red'. The Query Explorer is very helpful for testing API requests.

这篇关于使用和查询谷歌Analytics(分析)API定义维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆