user18577
user18577

Reputation: 643

Find segment ID in Google analytics?

I am trying to output the content of a Google Analytics segment using a script called Oochart.

To do this I need the segment ID, how do I find this?

Upvotes: 10

Views: 16761

Answers (4)

John Severinson
John Severinson

Reputation: 5325

While the best answer is the one from LCarey (to use the Query Explorer: http://ga-dev-tools.appspot.com/explorer/) I found that the answer from Pavel needs update if you want to go that way instead, as the URL structure has changed.

Consider the following URL:

https://analytics.google.com/analytics/web/#report/defaultid/a23080303w45291587p45450834/%3F_.useg%3DuserfSRDEURzSXe_Kspo6mxgXw/

You're looking for the string "_.useg%3Duser", after which the segment ID (fSRDEURzSXe_Kspo6mxgXw) follows. To use this in API I would use gaid::fSRDEURzSXe_Kspo6mxgXw.

Upvotes: 5

Pavel Jašek
Pavel Jašek

Reputation: 11

As LCarey briefly mentioned, you can read it from URL. I will clarify that by example.

Apply the segment and see the URL.

Example: https://www.google.com/analytics/web/#report/visitors-overview/a27824002w53282758p54121492/%3F_.advseg%3Duser1417962107/

You are looking for advseg parameter. In this case the segment ID is user1417962107. Characters %3D mean encoded equal sign "=".

In API you would use segment=gaid::user1417962107

Upvotes: 1

sk8asd123
sk8asd123

Reputation: 1705

The advanced segment feed provides a listing of all the default and user-created advanced segments. You can retrieve the ID of all the segments here in this standalone Explorer. (under the Try it! headline):

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/segments/list#try-it

You'll need to authenticate the requests using OAuth 2.0.

Upvotes: 2

LCarey
LCarey

Reputation: 111

There's no simple way. You either have to try to read it from the URL when you apply the segment, or select the segment in the query explorer (http://ga-dev-tools.appspot.com/explorer/) which will then show the segment ID.

Upvotes: 11

Related Questions