403 Permission denied error when retrieving advanced segment

6,558 views
Skip to first unread message

Admin Dwarf

unread,
Oct 23, 2012, 4:01:19 AM10/23/12
to google-analytics...@googlegroups.com
Hi,

We're experiencing problems with the Google Analytics API V3 when trying to retrieve advanced segments from the Google API PHP client. It throws the following 403 exception:

(403) User does not have permission to perform operation for this advanced segment.

The strange thing is that we can successfully extract data from the same segment through the API Query Explorer, so it's definitely not a problem with the segment itself.

The service account e-mail we're using is 543570...@developer.gserviceaccount.com.

Can anybody provide some insights to this problem?

Jeetendra Soneja

unread,
Oct 30, 2012, 12:29:56 AM10/30/12
to google-analytics...@googlegroups.com
An advanced segment in Google Analytics belongs to the user who created it and only that user has access to the segment. Since you're using a service account, it wouldn't have access to any of the saved advanced segments.

With service accounts, you could try using dynamic segments.

Fresh Egg

unread,
Nov 7, 2012, 7:34:52 AM11/7/12
to google-analytics...@googlegroups.com
We're having the same problem - Google.Apis.Requests.RequestError User does not have sufficient permissions for this advanced segment. [403]

We cannot use dynamic segments or filters because some of our custom segments are quite complex and generate a request longer than the maximum 2048 characters. The same requests do work with the API Query Explorer, so I guess the explorer doesn't query the API in the same way.

Is there really no way to do this with v3?

MoreVisibility

unread,
Nov 16, 2012, 1:41:41 PM11/16/12
to google-analytics...@googlegroups.com
Have hit this problem as well.

If anyone on Google API team can shed some light/patch this break, it would be most appreciated.

martbrow

unread,
Jan 22, 2013, 4:52:08 PM1/22/13
to google-analytics...@googlegroups.com
Is this behaviour by design?  I have run into the same issue described by everyone else on this thread.

The only segments returned are the 13 negatively numbered default segments.  I have tried adding new advanced segments to see if it was related to advanced segments created before the access was granted to the nnn...@developer.gserviceaccount.com type account.

Nick Blexrud

unread,
Feb 19, 2013, 3:47:07 PM2/19/13
to google-analytics...@googlegroups.com
Getting same error. Works with Query Explorer, but not with the API request. Anybody figure out a work around?

Nick Blexrud

unread,
Feb 20, 2013, 11:55:25 AM2/20/13
to google-analytics...@googlegroups.com
Figured out a temporary solution: Instead of using the advance segment, I created a new core report and simply used the filters ga:customVarValue1==example to get at the data I wanted. Required a little extra coding, but will work until this is patched.

David Kelly

unread,
Mar 21, 2013, 10:52:58 AM3/21/13
to google-analytics...@googlegroups.com
Did you find link between when the API Project and Auth Grant generation and when the advanced segments creation date?  I've also opened a bug report.  Perhaps this will help in getting rectified. 

Thanks

MoreVisibility

unread,
Mar 22, 2013, 8:04:41 AM3/22/13
to google-analytics...@googlegroups.com
Believe the issue with advanced segments is summarized in ownership.  User that creates the advanced segments will be able to use once authenticated in Reporting API queries.  If one authenticates with a different user in the API, they will only see the advanced segments they have created.

MoreVisibility

unread,
Mar 22, 2013, 8:07:01 AM3/22/13
to google-analytics...@googlegroups.com
UPDATE--- We were able to fix this by redoing the token and all is working now as expected. 

Admin Dwarf

unread,
Apr 16, 2013, 9:08:09 AM4/16/13
to google-analytics...@googlegroups.com
Are you saying you got advanced segments working for a non-owner account?
If so, did you have to do anything else than create a new token?

MoreVisibility

unread,
Apr 16, 2013, 9:49:08 AM4/16/13
to google-analytics...@googlegroups.com
Nope.  The regeneration of the token was performed via the profile that created the Advanced Segments.

Wowzamade

unread,
Nov 23, 2013, 6:30:55 PM11/23/13
to google-analytics...@googlegroups.com
Have you been able to access segments created by other accounts?

Pete

unread,
Nov 25, 2013, 11:47:27 AM11/25/13
to google-analytics...@googlegroups.com
To summarize earlier discussions:
1) A segment in Google Analytics belongs to the user who created it and only that user has access to the segment.
2) A service account will not have access to any of the saved advanced segments. For API requests you could try using dynamic segments instead.

So, a User has saved segments and those segments can be applied to any request for views (profiles) that the User has access to.

Example:
Assuming User A creates/saves a segment and User B also has saved segments and your application is authorized to access User A and B's Analytics account (i.e. they give permission to your App to access their data). The App would be able to retrieve the IDs of the saved segments for both users but you can't apply User A's segment ID to a request for User B's data. For that to work, User A would need to have access to User B's view (profile) to begin with.

Simon Tapson

unread,
Feb 26, 2014, 9:17:09 AM2/26/14
to google-analytics...@googlegroups.com
I am having exactly the same problem. My issue is that my filters/ dynamic segments are so long they exceed the GA API's maximum URL length. Has anyone found a solution to this problem yet?

Vishal Bedre

unread,
Oct 13, 2015, 3:20:41 PM10/13/15
to Google Analytics Reporting API

Need to create shared segment it will work... Cheers

Reply all
Reply to author
Forward
0 new messages