资源元数据

您可以使用 GoogleAdsFieldService 动态请求目录,以获取 GoogleAdsService SearchSearchStream 方法中提供的资源、资源的字段、细分键和指标。该目录提供了可供 Google Ads API 客户端用于验证和构建 Google Ads 查询语言语句的元数据。

示例 HTTP 请求和响应

该请求包含一个发送到以下网址的 Google Ads API 服务器的 HTTP GET

https://googleads.googleapis.com/v16/googleAdsFields/{resource_or_field}

下面是一个请求示例,后跟从 ad_group 资源的 GoogleAdsFieldService 返回的响应:

请求

https://googleads.googleapis.com/v16/googleAdsFields/ad_group

响应

{
  "resourceName": "googleAdsFields/ad_group",
  "name": "ad_group",
  "category": "RESOURCE",
  "selectable": false,
  "filterable": false,
  "sortable": false,
  "selectableWith": [
    "campaign",
    "customer",
    "metrics.average_cpc",
    "segments.device",
    ...
  ],
  "attributeResources": [
    "customer",
    "campaign"
  ],

  "metrics": [
    "metrics.conversions",
    "metrics.search_budget_lost_impression_share",
    "metrics.average_cost",
    "metrics.clicks",
    ...
  ],
  "segments": [
    "segments.date",
    "segments.ad_network_type",
    "segments.device",
    ...
  ]
}

在本例中,重要的数组是:

attributeResources
可隐式连接到 FROM 子句中的资源的资源。
metrics
可使用 FROM 子句中的资源选择的可用指标。仅针对 categoryRESOURCE 的字段填充数据。
segments
可使用 FROM 子句中的资源进行选择的细分键。它们会对查询中指定的指标进行细分。仅针对 categoryRESOURCE 的字段填充数据。
selectableWith
与给定字段一起选择的字段(当不在 FROM 子句中时)。此属性仅在识别能够在查询中选择的资源或细分(未包含在 FROM 子句中的资源中)时,才具有相关性。例如,如果我们从 ad_group 中选择 ad_group.idsegments.date,并且想要添加 campaign 中的属性,则需要检查 segments.date 是否在广告系列的 selectableWith 属性中,因为它是与现有的 segments.date 字段一起选择的。

元数据详情

您可以在以下级别使用 GoogleAdsFieldService 请求目录:

资源
例如 googleAdsFields/campaign
资源的字段
例如 googleAdsFields/campaign.name
细分字段
例如 googleAdsFields/segments.ad_network_type
指标
例如 googleAdsFields/metrics.clicks