The Google Ads Query Language can query the Google Ads API for
- Resources or metrics in
GoogleAdsServiceSearch or SearchStream
The result from a GoogleAdsService query is a list of
GoogleAdsRowinstances, with each
GoogleAdsRowrepresenting a resource. If metrics were requested, the row would also include metrics.
For a list of queryable metrics, such as impressions or clicks, consult the
- Metadata about available fields and resources in GoogleAdsFieldService
This service provides a catalog of queryable fields with specifics about their compatibility and type.
The result from a
GoogleAdsFieldServicequery is a list of
GoogleAdsFieldinstances, with each
GoogleAdsFieldcontaining details about the requested field.
Resources and metrics
When querying for metrics, you can also have the details of the associated resources returned at the same time. You can then immediately take those resources, modify them, and send them back to the service's mutate method. Here is a sample workflow:
- Query all the campaigns that are currently
PAUSEDand have impressions greater than 1000.
- Process each
GoogleAdsRowreturned in the list and retrieve the campaigns that are in each
- Change the status of each campaign from
CampaignService.MutateCampaignswith the modified campaigns to update them.
There are times when you may not care about metrics. Here's a query for campaigns showing how to get the campaign ID, name, and status:
SELECT campaign.id, campaign.name, campaign.status FROM campaign ORDER BY campaign.id
This query orders by campaign ID. Each resulting
GoogleAdsRow would have a
campaign populated with the selected fields.
To find out what other fields are available for campaign queries, consult the
When querying for metrics, you can query corresponding resources at the same time. Here's a query for campaigns showing how to get the campaign ID, name, status, and impressions:
SELECT campaign.id, campaign.name, campaign.status, metrics.impressions FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 ORDER BY campaign.id
This query filters for only the campaigns that have a status of
have had greater than 1000 impressions while ordering by campaign ID. Each
GoogleAdsRow would have a
metrics populated with the selected
For a list of queryable metrics, consult the
Queries sent to
GoogleAdsFieldService is meant for retrieving field metadata.
Here's a general query for metadata :
SELECT name, category, selectable, filterable, sortable, selectable_with, data_type, is_repeated WHERE name = <INSERT_RESOURCE_OR_FIELD>
You can replace
INSERT_RESOURCE_OR_FIELD in this query with either a resource
campaign) or a field (such as
For a list of queryable fields, consult the
The client libraries have examples of using the
Google Ads Query Language in
GoogleAdsService. The basic operations folder has
examples such as
The reporting folder has a