Access custom segments via the Google Analytics API?
-
I'd like to use some of my custom SEO-related segments in the Google Analytics API, but I can't seem to find how to do this.
Is it possible to access my GA custom segments via the API?
-
Hey there,
I was going to write up a full response, but honestly this video does it better than I even could. Have you seen it?
http://www.youtube.com/watch?v=7nJzwDIf7r4
Your specific question begins to get answered around 2:25 mark, but you might want to watch the whole thing to get context. The part about default and custom segments begins around 4:50.
Basically, you can either query for a dynamic segmentation ("on the fly"), one of the default segments (same as the ones in the GA interface like direct, search, mobile, etc.), or one of your custom segments that you created in the interface.
You're gonna have to grab the ID associated with your custom segment and call it with:
&segment=gaid::{whatever the id of your segment is}
The ID that you need will be listed in your XML account feed (around 5:15 in the video).
Hope that helps.