How to use segments in Google Analytics API

微笑、不失礼 提交于 2019-12-06 07:25:20

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.

Everything you send to the segment, actually anything you send to any of the parameter to the reporting API must be URL encoded.

users::condition::dateOfSession==2015-04-30;ga:sessionCount==1;condition::ga:campaign=@33100;sessions::condition::ga:userType=@Returning Visitor

becomes

users%3A%3Acondition%3A%3AdateOfSession%3D%3D2015-04-30%3Bga%3AsessionCount%3D%3D1%3Bcondition%3A%3Aga%3Acampaign%3D%4033100%3Bsessions%3A%3Acondition%3A%3Aga%3AuserType%3D%40Returning+Visitor

That should work. the only thing I am not sure about is if the ; needs to be encode or not. You may need to test that. I know the == does. If it doesn't work let me know and I will add a few segments and do some testing myself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!