Google Analytics API - retrieve Custom Segment Id by its name

前端 未结 2 1379
灰色年华
灰色年华 2020-12-18 11:42

Using Google Analytics API to retrieve 20+ Profiles\' data so i can combine all of them into one set of data for analysis. (separate profiles are for different domains that

2条回答
  •  独厮守ぢ
    2020-12-18 12:33

    The answer is that the Analytics Core Reporting API doesn't have access to the custom segments. They can only be accessed by the Analytics Management API as referenced here:

    Retrieve a user's Custom Segments to apply them to Core Reporting API queries. https://developers.google.com/analytics/devguides/config/mgmt/v3/

    So looks like I will have to make call to Analytics Management API first to get list of custom segments that I want, and then use that list in Analytics Core Reporting API call to get data for just those segments.

    https://developers.google.com/analytics/devguides/reporting/core/v3/reference#segment

    Alternatively, I can forget about using the custom segments and instead retrieve Session Hostname and Source in Analytics Core Reporting API call data, so that I can do same filter in the query or in report as my custom segment. Drawback is that the referral spam is about 80% + of Google Analytics data so I would be retrieving more data than i need on regular basis.

提交回复
热议问题