Skip to content
Alpue Studio

Blog / Google Ads

GAQL examples for common Google Ads questions

GAQL, the Google Ads Query Language, is how you ask the Google Ads API for data. A query has up to six clauses, and SELECT and FROM are required. Ten GAQL examples follow, for questions account managers ask. Their field names were checked against Google's v26 fields reference as of November 2026, and each comes with a note on where a query returns more rows or different numbers than you expect.

How a GAQL query is built

Google's query structure page names six clauses. They are SELECT, FROM, WHERE, ORDER BY, LIMIT and PARAMETERS, and SELECT and FROM are required for GoogleAdsService. FROM takes a single resource, such as campaign or keyword_view, and that resource decides which fields the rest of the query may use. Fields of related resources, which Google calls attributed resources, join implicitly. Selecting campaign.name in a query on ad_group is enough to get it.

The grammar page says WHERE combines conditions only with AND. A logical OR is not supported, so you use IN or REGEXP_MATCH instead. LIMIT takes a positive integer. PARAMETERS, the sixth clause, holds meta settings, and the structure page lists include_drafts and omit_unselected_resource_names.

Dates are either predefined ranges or custom dates, according to the date ranges page. DURING accepts a predefined range such as LAST_30_DAYS, which covers the last 30 days not including today. Custom dates use BETWEEN '2026-11-01' AND '2026-11-15', and DURING cannot take them. Ranges are evaluated in the serving account's time zone, which can differ from the time zone of your client.

What changes the numbers

Money fields end in _micros. Google's campaign_budget reference says one million micros is equivalent to one currency unit, so a cost_micros of 1230000 is 1.23 in the account currency.

Segments split rows. The segmentation page says each segment you select produces a row per combination, and that extra segments can increase the row count exponentially. A segment in WHERE must also be in SELECT, except the core date segments (segments.date, segments.week, segments.month, segments.quarter, segments.year).

Some metrics and segments cannot sit together. The API answers with errors such as PROHIBITED_SEGMENT_WITH_METRIC_IN_SELECT_OR_WHERE_CLAUSE, described in the QueryError reference. Metrics cannot be requested for a manager account, and the same reference says to send separate requests to each client account.

Campaign results and budgets

Google's use case example summarizes an account over the last 30 days by campaign and device. This version drops the device split, adds conversions and sorts by spend.

SELECT campaign.id, campaign.name, campaign.status,
  campaign.advertising_channel_type,
  metrics.impressions, metrics.clicks, metrics.cost_micros,
  metrics.conversions, metrics.conversions_value
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
  AND campaign.status != 'REMOVED'
ORDER BY metrics.cost_micros DESC

The status filter comes from a note in Google's query cookbook, which says to add it when the Google Ads screens you compare against exclude removed parent entities.

For budgets against spend, campaign_budget fields can be selected from campaign.

SELECT campaign.name, campaign.status,
  campaign_budget.amount_micros, campaign_budget.explicitly_shared,
  campaign_budget.period, campaign_budget.total_amount_micros,
  metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
  AND campaign.status = 'ENABLED'
ORDER BY metrics.cost_micros DESC

The field reference describes amount_micros as the average daily amount, used when the period is DAILY, with effective monthly spend capped at 30.4 times that amount. Because it is an average, a single day above it does not mean the budget was exceeded, so compare a month of spend with the cap. A budget with CUSTOM_PERIOD uses total_amount_micros instead. When explicitly_shared is true, the budget was created to be shared across one or more campaigns. Each of those campaigns' rows then shows the same budget amount, so add up their spend before you compare it.

Results by device and by geography

Add segments.device to the campaign query to split results by device.

SELECT campaign.name, segments.device,
  metrics.impressions, metrics.clicks, metrics.cost_micros,
  metrics.conversions
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
  AND campaign.status != 'REMOVED'
ORDER BY campaign.name, metrics.cost_micros DESC

For geography the resource is geographic_view. Its description says it aggregates by country with one row per country, that it reports either the user's physical location or an area of interest, and that other segments can add rows.

SELECT geographic_view.country_criterion_id,
  geographic_view.location_type,
  metrics.clicks, metrics.cost_micros, metrics.conversions
FROM geographic_view
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESC

location_type is LOCATION_OF_PRESENCE or AREA_OF_INTEREST, and selecting it shows which of the two a row reports. The result carries a criterion ID where you might expect a country name. The cookbook looks locations up with a second query on geo_target_constant.

Search terms and keywords

Search terms that spent money and did not convert are the usual starting list for negative keywords.

SELECT search_term_view.search_term, search_term_view.status,
  campaign.name, ad_group.name,
  metrics.clicks, metrics.cost_micros, metrics.conversions
FROM search_term_view
WHERE segments.date DURING LAST_30_DAYS
  AND metrics.cost_micros > 0
  AND metrics.conversions = 0
ORDER BY metrics.cost_micros DESC
LIMIT 100

The resource's description says it aggregates by search term at the ad group level and leaves out Performance Max, which has its own campaign_search_term_view. Because rows are per ad group, one term can appear several times. The segmentation page says they are separate rows that belong to different ad groups. A term with zero conversions in one ad group may convert in another, so total the term before you exclude it.

The report also hides some terms. Google's help page on the search terms report says it was changed to meet privacy thresholds, so only terms with enough search volume across Google searches appear. In a 2021 forum thread a developer found search_term_view impressions and cost lower than keyword_view for the same dates. Another developer there put the gap down to undisclosed search terms. The Google advisors suggested the two reports accumulate data at different levels and asked for request logs, and the thread does not settle the cause.

Quality score is not under metrics. It sits under ad_group_criterion.quality_info, next to three components, each an enum with the values ABOVE_AVERAGE, AVERAGE and BELOW_AVERAGE.

SELECT campaign.name, ad_group.name,
  ad_group_criterion.keyword.text,
  ad_group_criterion.keyword.match_type,
  ad_group_criterion.quality_info.quality_score,
  ad_group_criterion.quality_info.creative_quality_score,
  ad_group_criterion.quality_info.post_click_quality_score,
  ad_group_criterion.quality_info.search_predicted_ctr,
  metrics.cost_micros
FROM keyword_view
WHERE segments.date DURING LAST_30_DAYS
  AND ad_group_criterion.status != 'REMOVED'
  AND ad_group_criterion.quality_info.quality_score < 5
ORDER BY metrics.cost_micros DESC
LIMIT 100

The reference says quality_score may not be populated when Google lacks enough information, so a keyword can lack a value. The query filters on a threshold of 5, which is a choice and not a rule from the documentation.

Ads and asset groups

Ads with policy problems

Policy status lives on ad_group_ad.policy_summary. The approval status is APPROVED, APPROVED_LIMITED, AREA_OF_INTEREST_ONLY or DISAPPROVED.

SELECT campaign.name, ad_group.name,
  ad_group_ad.ad.id, ad_group_ad.ad.type, ad_group_ad.status,
  ad_group_ad.policy_summary.approval_status,
  ad_group_ad.policy_summary.review_status,
  ad_group_ad.policy_summary.policy_topic_entries
FROM ad_group_ad
WHERE ad_group_ad.status != 'REMOVED'
  AND ad_group_ad.policy_summary.approval_status
    IN ('DISAPPROVED', 'APPROVED_LIMITED')

policy_topic_entries is the list of policy findings for the ad. It can be selected but not filtered, so filter on the approval status and read the entries in the result.

Performance Max asset groups

Google's cookbook queries asset_group for the asset groups screen. This version covers 30 days and adds conversion value.

SELECT asset_group.name, campaign.name, asset_group.status,
  asset_group.ad_strength,
  metrics.clicks, metrics.impressions, metrics.cost_micros,
  metrics.conversions, metrics.conversions_value
FROM asset_group
WHERE segments.date DURING LAST_30_DAYS
  AND asset_group.status != 'REMOVED'
ORDER BY metrics.cost_micros DESC

The cookbook's date default is the last seven days, so say the range you want. For Performance Max search terms use campaign_search_term_view, whose description warns that selecting keyword segments removes Performance Max data.

Change history and conversion actions

change_event answers who changed what. Google's change event guide sets three rules. The date filter must fall within the past 30 days, the window is at most 30 days (stated in the guide's code samples), and a LIMIT of at most 10,000 rows is required.

SELECT change_event.change_date_time, change_event.user_email,
  change_event.client_type, change_event.change_resource_type,
  change_event.resource_change_operation,
  change_event.change_resource_name, change_event.changed_fields
FROM change_event
WHERE change_event.change_date_time >= '2026-11-12'
  AND change_event.change_date_time <= '2026-11-27'
ORDER BY change_event.change_date_time DESC
LIMIT 200

The guide says a change can take up to three minutes to show up and that the resource may leave out changes the Change History screen shows. For a fuller view it points to the change status resource. The query's upper date is tomorrow, as in several of Google's samples.

To see which conversion actions feed the conversions metric, query conversion_action with no date range.

SELECT conversion_action.id, conversion_action.name,
  conversion_action.type, conversion_action.category,
  conversion_action.status, conversion_action.primary_for_goal,
  conversion_action.include_in_conversions_metric
FROM conversion_action
WHERE conversion_action.status != 'REMOVED'

Per the field reference, when primary_for_goal is false the action is non-biddable whatever a campaign's own goals say, except that custom conversion goals ignore the flag.

Where to run a query

Google's Query Builder assembles a query from a chosen resource and its compatible fields. The Query Validator checks pasted text for syntax, field spelling and segment and metric compatibility, and its page says its error messages sometimes suggest compatible resources. Paste each query above there first. The API Explorer then runs it against live data from the browser.

In code, the query goes to GoogleAdsService through Search or SearchStream, and the cookbook shows curl requests. Production accounts need an access level on the Google Cloud project. As of November 2026 Explorer access allows up to 2,880 operations a day against production accounts, per the access levels page, which also says developer tokens were sunset on September 9, 2026 and access levels now belong to the Cloud project.

The Google Ads MCP server gives an AI client a GAQL search tool. Alpue Studio's agent writes its own GAQL against a connected Google Ads account, and each query it ran opens under "See query". It reads with these queries. A change reaches an ad account only when a person drags a slider, and Alpue Studio is not an MCP server. The Google Ads integration page has the details, and the audit checklist lists the API field each check reads.

Questions

What is GAQL?

It is the query language of the Google Ads API, described on Google's query overview page. It returns resources, their attributes, segments and metrics through GoogleAdsService, and field metadata through GoogleAdsFieldService.

Is GAQL the same as SQL?

It reads like SQL and differs in places. The FROM clause names one resource, related resources join implicitly, and WHERE combines conditions with AND only, so there is no OR. Google's pages do not compare GAQL with SQL directly, so those points come from the grammar and structure pages.

Why is cost shown in micros?

The API returns money as integers in millionths of the account currency. A cost_micros of 45000000 is 45, so divide by 1,000,000 before you report it.

Can the same query break after an API upgrade?

The query overview says syntax, clauses and operators are identical across v23 to v26, while the catalog of resources, segments and metrics differs by version. Query GoogleAdsFieldService at your target version to check a field.

Sources

Keep reading. Google Ads

The posts on this topic →

Brief the agent. Approve what it builds.

Alpue Studio reads your ad accounts, runs code on the data and prepares campaigns and reports. Your accounts stay read-only until someone on your team slides.