从 Google Analytics API 获取所有配置文件

Getting all profiles from Google Analytics API

我正在尝试通过此端点使用 ~all 选项获取所有配置文件

https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles

它没有 return 所有配置文件,因为 ~all 用于帐户。如果我包含帐户 ID 而不是 ~all,那么它 returns 基于该帐户 ID 的配置文件 - 当与 ~all 选项一起使用时会丢失。

https://www.googleapis.com/analytics/v3/management/accounts/89478503/webproperties/~all/profiles

我是做错了什么还是这个 GA API 错误?

我建议您考虑使用 account summaries list

GET https://www.googleapis.com/analytics/v3/management/accountSummaries

这将return 一个用户的所有帐户信息。

{
  "kind": "analytics#accountSummaries",
  "username": "me@gmail.com",
  "totalResults": 15,
  "startIndex": 1,
  "itemsPerPage": 1000,
  "items": [
    {
      "id": "59183475",
      "kind": "analytics#accountSummary",
      "name": "Cube Analytics",
      "webProperties": [
        {
          "kind": "analytics#webPropertySummary",
          "id": "UA-59183475-1",
          "name": "Cube Analytics",
          "internalWebPropertyId": "93305066",
          "level": "STANDARD",
          "websiteUrl": "XXXXXXX",
          "profiles": [
            {
              "kind": "analytics#profileSummary",
              "id": "115455750",
              "name": "Alaternate",
              "type": "WEB"
            },
            {
              "kind": "analytics#profileSummary",
              "id": "97191919",
              "name": "All Web Site Data",
              "type": "WEB"
            },
            {
              "kind": "analytics#profileSummary",
              "id": "178538323",
              "name": "MobileView",
              "type": "APP"
            }
          ]
        },      ]
}

通过使用此调用,您只需拨打一次电话即可获得所有信息。