AI-generated Key Takeaways
-
GoogleAdsFieldServiceallows dynamic requests for catalog information about resources, fields, segmentation keys, and metrics available inGoogleAdsServiceSearch and SearchStream methods. -
The catalog provides metadata used by Google Ads API clients for validating and constructing Google Ads Query Language statements.
-
You can request the catalog using
GoogleAdsFieldServiceat the levels of Resource, Resource's field, Segmentation field, and Metric. -
The example response shows important arrays like
attributeResources,metrics,segments, andselectableWiththat provide information about joinable resources, available metrics, segment keys, and selectable fields.
You can use GoogleAdsFieldService
to dynamically request the catalog for resources, resource's fields,
segmentation keys and metrics available in the
GoogleAdsService Search and
SearchStream methods. The catalog provides metadata that can be used by
Google Ads API clients for validation and construction of Google Ads Query Language statements.
Sample HTTP request and response
The request consists of an HTTP GET to the Google Ads API server at the following
URL:
https://googleads.googleapis.com/v22/googleAdsFields/{resource_or_field}
The following example shows a request followed by the response returned from
GoogleAdsFieldService for the ad_group resource:
Request
https://googleads.googleapis.com/v22/googleAdsFields/ad_group
Response
{
"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",
...
]
}
For this example, the important arrays are:
attributeResources- Resources that can be implicitly joined to the resource in the
FROMclause. metrics- Metrics that are available to be selected with the resource in the
FROMclause. Only populated for fields where thecategoryisRESOURCE. segments- Segment keys that can be selected with the resource in the
FROMclause. These segment the metrics specified in the query. Only populated for fields where thecategoryisRESOURCE. selectableWith-
The
selectableWithattribute on a resource or segment field specifies other resources, segments, or metrics that can be selected in the same GAQL query. This attribute is crucial when you want to include fields from a resource or segment that is not specified in theFROMclause.When constructing a GAQL query:
- The resource in the
FROMclause is the primary entity. You can always select fields from this resource. - You can also select compatible metrics and segments that are available with the primary entity.
- If you include fields from any resource or segment outside of the
FROMclause, you must ensure that this non-FROMresource or segment is compatible with all other fields, segments, and metrics that are selected in the query.
- The resource in the
The
selectableWithlist for a specific resource (let's call it Resource A) contains all the other resources, segments, and metrics that can be selected alongside fields from Resource A when Resource A is not the primary entity.Example:
Consider this example query:
SELECT ad_group.id, segments.date, campaign.name FROM ad_groupThe
FROMclause specifiesad_group.This query selects
ad_group.id(from theFROMresource),segments.date, andcampaign.name.Because
campaign.nameis selected, butcampaignis not in theFROMclause, you must verify its compatibility with other selected elements.To ensure this query is valid, the
campaignresource must be compatible withsegments.date(another field being selected). Therefore, you must check theselectableWithattribute for thecampaignresource. Ifsegments.dateis present incampaign'sselectableWithlist, the query is valid.
If you select fields from a resource that is not in the
FROMclause, that resource'sselectableWithlist must include all other segments and resources present in yourSELECTclause.
Metadata details
You can request the catalog using the GoogleAdsFieldService at these levels:
- Resource
- For example,
googleAdsFields/campaign. - Resource's field
- For example,
googleAdsFields/campaign.name. - Segmentation field
- For example,
googleAdsFields/segments.ad_network_type. - Metric
- For example,
googleAdsFields/metrics.clicks.