Ryan
Ryan

Reputation: 31

Google Analytics API Response - "User does not have sufficient permissions for this advanced segment" but they do

Using the GA API with a particular segment, the authenticated token is from an admin who created the segment. The segment was shared with the permissions for "Collaborators and I can apply/edit Segment in this View"

I've verified the Property ID, View ID, and Segment ID from the interface with the API call. The GA API returns "User does not have sufficient permissions for this advanced segment."

The user created the segment and shared it, so I'm at a bit of a loss as to why I get this error response. Any help would be much appreciated. Thanks!

Upvotes: 3

Views: 4616

Answers (3)

Murray Howell
Murray Howell

Reputation: 21

@Ash has the correct answer but here is a more detailed response:

  1. The user that created the Segment must open complete the following in Google Analytics:
  2. Open the segment panel and select 'Custom', then click 'Edit' for the segment you would like to share.
  3. Then click 'Change' in the top right corner.
  4. You can now select the option allowing collaborators to apply and edit the segment within the view.
  5. Save your changes.

This will allow you to query the custom segment using a service API.

Upvotes: 2

Ash
Ash

Reputation: 1466

I was facing same issue and the error was:

HttpError 403 when requesting https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json returned
 "User does not have sufficient permissions for this advanced segment."

Creating shared Segment resolved above issue.

Credits and more info: Google groups

Upvotes: 0

Zed
Zed

Reputation: 34

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.

Upvotes: 1

Related Questions