如何在Google AnalyticsAPI中使用细分受众群 [英] How to use segments in Google Analytics API
问题描述
在Google Analytics中,我们可以创建如下所示的细分: $ b
从谷歌分析API浏览器,我们可以通过segment id或其代码来获取细分信息: img src =https://i.stack.imgur.com/T4CPl.pngalt =我在这里假设我们可以将这些代码剪切并粘贴到Google分析报告核心报告v3参考代码中,就像我们对所有其他参数所做的一样: 当我运行代码时,出现以下错误: 我不确定可能会出现什么问题。当我在段代码中使用segment id代替segment参数(segment ='gaid :: xxxxxxx')时,出现以下错误: 不知道应该如何构造代码。 我在使用细分代码调整后发现了解决方案,并在段dev的指南。 我遇到了dateOfsession参数问题,我应该在日期中使用'<''而不是'='。所以这是我应该做的:
Arg,有一个API错误:400:无效值'users :: condition :: dateOfSession == 2015-04-30; ga:sessionCount == 1;条件:: GA:运动= @ 33100; SE ssions :: condition :: ga:userType = @为段参数返回访问者
。
Arg,出现API错误:400:该API不支持分段XXXXXXXXXXX。
dateOfsession<> 2015-04-30_2015-04-30
不知何故,使用'=='不起作用。
dateOfsession是GA API中的一个新参数,因此几乎没有关于它的示例和文档。
In Google Analytics, we are able to create segments like below:
From the Google Analytics API explorer, we can pull the segment information be it by segment id or by its code:
I would assume we can just cut and paste that code into the google analytics core reporting v3 reference code like we do with all the other parameters:
When I run the code however, I get this error:
Arg, there was an API error : 400 : Invalid value 'users::condition::dateOfSession==2015-04-30;ga:sessionCount==1;condition::ga:campaign=@33100;sessions::condition::ga:userType=@Returning Visitor'
for segment parameter.
I am not sure what could be wrong. When I use the segment id instead in my code for the segment parameter(segment ='gaid::xxxxxxx'), i get this error:
Arg, there was an API error : 400 : Segment XXXXXXXXXXX is not supported in the API.
Not sure how I should structure the code.
I found the solution after tweaking with the segment code and reading more about segments in the segments dev guide.
I was having issues with the dateOfsession parameter where i should have used '<>' instead of '=' for the date. So this is what i should have done:
dateOfsession<>2015-04-30_2015-04-30
Somehow using '==' doesn't work.
The dateOfsession is a new parameter in the GA API and hence have little examples and documentation about it.
这篇关于如何在Google AnalyticsAPI中使用细分受众群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!