Search code examples
apigoogle-maps-api-3servicegoogle-analyticsgoogle-analytics-api

Google Analytics - Service Account and Segments


I've created an app for Google Analytics in the API console. I am trying to list out custom segments that have been created, but have noticed that I cannot view existing Segments that have been created.

I followed this example: Service Applications and Google Analytics API V3: Server-to-server OAuth2 authentication?

For instance, I log in to my google analytics account, grant access to a profile, then in the google analytics profile, I create a sample segment.

Calling this:

$service->management_segments->listManagementSegments();

I would expect to see my "test segment" but don't see it.

Is there an additional step that I would need to grant my service account the ability to see the custom segments setup?

This example here shows the custom segments:

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

I am hoping someone can clarify the workflow. Thanks!


Solution

  • Since segments are tied to google accounts, not service accounts, they aren't available. It's best to grab segment definitions using the web server workflow, or use dynamic filters instead of segments.