›

›

Google Ads Query Language (GAQL): Syntax and 12 Practical Examples

Blog

Google Ads Query Language (GAQL): Syntax and 12 Practical Examples

Eren Korkmaz, Head of Growth at turnalar

Eren Korkmaz

18 Min Read

Google Ads Query Language (GAQL) is the reporting language for retrieving campaign data, metrics and segments from Google Ads. Learn the syntax, explore 12 practical examples and test queries on simulated data without an advertising account.

Editorial illustration of a GAQL code editor transforming an advertising query into a structured reporting table.
▪ GAQL WORKBENCH

GAQL Playground

Build GAQL using an expanded field catalog, or test supported queries on simulated data. No Google Ads connection.

8 resources · 46 fields with simulated data. Run queries locally.
QUERY.GAQL10 lines
Choose an example, explore the catalog and validate or run a demo.
Query results
6 rows shown / 6 matching · simulated
campaign.nameimpressionsclickscost_micros ($)conversions
Search | Generic15,0901,180$1,522.8263
Search | Brand14,1101,100$1,428.8862
PMax | Retail14,4601,116$1,407.7860
Shopping | Essentials13,4301,048$1,347.2060
Search | Research13,1401,027$1,339.670
Search | Legacy00$0.000
1–6 of 6
Supported grammar & demo limitations

Build & Validate uses an expanded, curated v26 catalog or a user-imported field metadata snapshot. Local checks cover field membership, basic compatibility, SELECT, FROM, WHERE, AND, comparisons, IN, NOT IN, BETWEEN, LIKE, NOT LIKE, DURING, ORDER BY and LIMIT, with additional operators in catalog mode. They are not a substitute for Google’s API validator. Run Demo supports a smaller executable subset. Data covers Nov 5–Dec 4, 2026 (fixed demo clock Dec 5). Demo interactions equal clicks, All conversions equal conversions, and network labels are illustrative. Resource datasets do not reconcile across reports. CSV uses raw values. Maximum 200 demo result rows. No account data or API requests.

Before production, use the official Google query validator and v26 field reference.

Google Ads Query Language (GAQL) lets you turn a question about an advertising account into a repeatable report. Instead of opening several screens, exporting spreadsheets and manually combining them, you can specify the entities, metrics, date range and conditions you need in a single query. It is the foundation of reporting in the Google Ads API and modern Google Ads Scripts.

This guide is written for PPC specialists, marketing analysts and developers. Build & Validate opens the expanded v26 field catalog with 47 resources and 457 distinct fields. Run Demo executes supported queries on a simulated retail account with eight resources and 46 fields. No account access is required. The local catalog and parser cover a curated subset of the API; import a full field metadata snapshot if you have one, and use Google’s official validator for production. The examples use API v26.

Open the standalone GAQL Query Builder →

What Is Google Ads Query Language (GAQL)?

GAQL is Google’s reporting query language for the Ads API. It retrieves structured rows representing entities such as campaigns, ad groups, ads and keyword criteria, as well as reporting views such as search terms and landing pages. It also retrieves performance metrics and segments. A query describes the information you want, not a sequence of actions that changes an account.

GAQL vs. SQL vs. AWQL

Feature

GAQL

SQL / AWQL

Purpose

Google Ads reporting

SQL: general relational databases; AWQL: legacy Ads reporting

Relationships

Resource-defined field compatibility

SQL: explicit JOIN; AWQL: predefined reports

Aggregation

Determined by resource and segments

SQL: GROUP BY and aggregate functions

Conditions

AND, supported field operators

SQL: broader boolean expressions

Changes

Read-only reporting

SQL may write; AWQL is legacy

GAQL resembles SQL, but thinking of it as a general SQL database often leads to mistakes. There is no arbitrary JOIN, GROUP BY, SUM or calculated expression in SELECT. The FROM resource determines the available fields and the grain of the report. To change campaigns or bids, use authorized mutation services or the appropriate Ads Scripts entities, not GAQL.

How GAQL Works: Resources, Metrics and Segments

Choose the reporting resource first

Start from the question you want answered. Campaign spend belongs in campaign; an actual search typed by a user belongs in a search-term reporting view. The same metric name can appear in several resources, but the meaning of each row changes. Include an ID whenever the result will be used by a script or matched to an external database. Names can be edited or reused.

Field type

Example

What it tells you

Resource attribute

campaign.name

Identity or configuration

Metric

metrics.clicks

Measured performance

Segment

segments.device

How performance is split

Attributed resource

campaign.name from keyword_view

Related resource information

Segmentation and implicit relationships

GAQL automatically exposes compatible attributes from related resources. You do not write joins. Adding a segment changes the granularity of the returned metrics. A campaign query may return one row per campaign; selecting segments.date and segments.device breaks those totals down by date and device. Some segments also exclude traffic for which they do not apply. Keyword-related segments, for example, can exclude Shopping, Dynamic Search Ads and Performance Max traffic.

Treat report grain as a contract. If your dashboard expects campaign-level totals, do not silently append segments.date. If you need daily reporting, use campaign ID and date as the key. When reconciling query output with another report, match both the date window and the dimensions.

GAQL Syntax and Query Structure

Clause

Required?

Purpose

SELECT

Yes

List the resource fields, metrics and segments

FROM

Yes for Ads reporting

Choose the primary resource

WHERE

No

Restrict dates, attributes and metrics

ORDER BY

No

Sort one or more selected fields

LIMIT

No

Cap returned rows

PARAMETERS

No

Configure supported request options

SELECT, FROM and WHERE

SELECT campaign.id, campaign.name, metrics.clicks,
metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_30_DAYS

SELECT specifies columns. FROM identifies the main reporting resource. WHERE reduces the scope. Filtering on a core date segment is not the same as selecting that segment: a last-30-days campaign query returns aggregated metrics unless you add a breakdown to SELECT.

ORDER BY, LIMIT and PARAMETERS

ORDER BY sorts results; DESC gives descending order and ASC ascending order. LIMIT is useful for top-spend reports or testing, but it is not a way to obtain a complete dataset. PARAMETERS supports specific request options such as omit_unselected_resource_names. Consult the official grammar before using these options; the playground does not implement PARAMETERS.

GAQL Operators and Date Ranges

Operator

Example

Use

=, !=

campaign.status = ‘ENABLED’

Exact value

>, >=, <, <=

metrics.cost_micros > 100000000

Comparison

IN / NOT IN

campaign.status IN (‘ENABLED’, ‘PAUSED’)

Set membership

LIKE / NOT LIKE

campaign.name LIKE ‘%Brand%’

Text pattern

REGEXP_MATCH

campaign.name REGEXP_MATCH ‘.*Brand.*’

Official regex matching

BETWEEN

segments.date BETWEEN ‘2026-12-01’ AND ‘2026-12-04’

Date bounds

DURING

segments.date DURING LAST_7_DAYS

Predefined range

CONTAINS ANY / ALL / NONE

Supported repeated fields

Collection membership

Use AND between conditions. GAQL does not support general OR expressions or arbitrary parenthesized boolean logic. Where appropriate, use IN for repeated equality checks on one field. Otherwise run separate queries and combine results carefully. The playground supports a limited operator set and reports unsupported expressions instead of pretending to run them.

Common date literals

Literal

Meaning

TODAY / YESTERDAY

Current day or previous day

LAST_7_DAYS

Seven completed days, excluding today

LAST_14_DAYS

Fourteen completed days, excluding today

LAST_30_DAYS

Thirty completed days, excluding today

THIS_MONTH / LAST_MONTH

Calendar month

Custom BETWEEN

Exact start and end dates

Real API date ranges follow the serving account’s time zone. The demo has a fixed reference date of December 5, 2026, and covers November 5 through December 4, so results are reproducible. It supports YESTERDAY, LAST_7_DAYS, LAST_14_DAYS, LAST_30_DAYS and explicit date comparisons. When selecting a core date segment, supply a finite date range. Granular date data also has retention limits, including a 37-month lookback limit in recent API versions.

How to Build Your First GAQL Query

Choose Campaign performance in the playground above. Change LAST_30_DAYS to LAST_7_DAYS and press Run query. Notice how the same campaigns now report a shorter period. Next, add segments.device to SELECT. This splits performance by device. Try ORDER BY metrics.cost_micros DESC LIMIT 2 to isolate the two highest-spend rows.

Use the visual builder or the code editor

The visual builder lets you choose a resource, search Attributes, Metrics and Segments, check field descriptions and select compatible fields from the local catalog. The editor suggests matching fields as you type. Validate query checks the selected catalog and supported grammar. Run demo executes only fields backed by the simulated dataset; unsupported combinations never return fabricated rows. CSV exports raw values. Visual controls support one additional filter, so keep complex conditions in the editor.

Google Ads Query Builder and Validator

Google’s official Query Builder explores the exact fields and compatibility rules for an API version. The turnalar workbench includes a curated v26 field catalog and an optional local import of GoogleAdsFieldService metadata. It does not call Google Ads or guarantee that every locally valid combination will be accepted by the API. Use the official Query Validator before production.

Google’s official Query Validator

Google Ads API v26 field catalog

GAQL Resources and Metrics Cheat Sheet

Google Ads report

FROM resource

Campaigns

campaign

Ad groups

ad_group

Ads

ad_group_ad

Search keywords

keyword_view

Search terms

search_term_view

Performance Max search terms

campaign_search_term_view

Shopping product performance

shopping_performance_view

Landing pages

landing_page_view

Conversion action settings

conversion_action

Change history

change_event

Common PPC metrics and their units

To interpret visibility and auction competition, see our Google Ads Auction Insights guide.

Field

Interpretation

Unit

metrics.impressions

Ad impressions

Count

metrics.clicks

Clicks

Count

metrics.cost_micros

Advertising cost

Micros

metrics.conversions

Conversions included in Conversions

Possibly fractional count

metrics.conversions_value

Reported conversion value

Account currency

metrics.ctr

Click-through rate

Decimal ratio

metrics.average_cpc

Average cost per click

Micros

metrics.cost_per_conversion

Average cost per conversion

Micros

metrics.conversions_value_per_cost

Conversion value / cost

Ratio

Divide monetary micros by 1,000,000 to obtain account currency; multiply CTR by 100 for a percentage. Calculate portfolio CPA as total cost divided by total conversions, not an average of campaign CPAs. The demo offers friendly display units and raw values. If conversions are zero, treat CPA as undefined for decision-making rather than interpreting a zero as good efficiency.

12 Practical GAQL Query Examples

Every example below has a matching template in the playground. Select the template, modify the conditions and run it. The output is illustrative, not advertiser data.

1. Campaign performance report

SELECT campaign.name, metrics.impressions, metrics.clicks,
metrics.cost_micros, metrics.conversions
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESC
LIMIT 20

Try this query in the builder →

Start here when reconciling spend and conversions. Add campaign.id as a durable join key. Look at cost, conversions and conversion value together before reallocating budgets.

2. Daily performance trend

SELECT campaign.name, segments.date, metrics.clicks,
metrics.cost_micros, metrics.conversions
FROM campaign
WHERE segments.date DURING LAST_7_DAYS
ORDER BY segments.date DESC
LIMIT 50

Try this query in the builder →

Daily rows enable pacing and anomaly checks. Remove LIMIT for a complete production extract. Compare completed days against an appropriate baseline, accounting for weekends, promotions and conversion lag.

3. Device performance

SELECT campaign.name, segments.device, metrics.clicks,
metrics.ctr, metrics.conversions
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.clicks DESC
LIMIT 30

Try this query in the builder →

Device segmentation can reveal different behavior on mobile and desktop. Add cost and inspect the mobile landing-page experience before concluding one device is inherently worse.

4. High spend without conversions

SELECT campaign.name, metrics.cost_micros, metrics.conversions
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
AND metrics.cost_micros > 100000000
AND metrics.conversions = 0
ORDER BY metrics.cost_micros DESC
LIMIT 20

Try this query in the builder →

100,000,000 micros equals 100 units of account currency. Investigate zero-conversion results instead of automatically pausing campaigns. Check tracking, objectives, lag and whether enough spend has accumulated.

5. Ad group performance

SELECT campaign.name, ad_group.name, metrics.clicks,
metrics.cost_micros, metrics.conversions
FROM ad_group
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESC
LIMIT 30

Try this query in the builder →

Compare ad groups with similar intent and conversion objectives. Investigate differences in keywords, creatives and landing pages.

6. Keyword performance

SELECT campaign.name, ad_group_criterion.keyword.text,
ad_group_criterion.keyword.match_type, metrics.clicks,
metrics.cost_micros, metrics.conversions
FROM keyword_view
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESC
LIMIT 30

Try this query in the builder →

Use the keyword report for targets you bid on, not actual user searches. In production include criterion ID and status; distinguish removed, paused and enabled keywords.

7. Search term review

SELECT campaign.name, search_term_view.search_term,
metrics.clicks, metrics.cost_micros, metrics.conversions
FROM search_term_view
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESC
LIMIT 30

Try this query in the builder →

Find irrelevant searches and new keyword opportunities. Review context before adding negatives. Privacy and reporting thresholds can omit search terms, so visible rows need not add up to total campaign spend.

Read our guide to the Google Ads search terms report

8. Performance Max search terms

SELECT campaign.name, campaign_search_term_view.search_term,
metrics.clicks, metrics.cost_micros, metrics.conversions
FROM campaign_search_term_view
WHERE segments.date DURING LAST_30_DAYS
AND campaign.advertising_channel_type = 'PERFORMANCE_MAX'
ORDER BY metrics.cost_micros DESC
LIMIT 30

Try this query in the builder →

Use campaign_search_term_view for PMax, not search_term_view. Keyword-related segments can filter PMax traffic out of the results. Search term insights are a separate approach to category and subcategory reporting.

For context on automated expansion and monitoring, read our Google Ads AI Max guide.

9. Ad performance

SELECT ad_group_ad.ad.id, ad_group_ad.status, campaign.name,
metrics.impressions, metrics.clicks, metrics.conversions
FROM ad_group_ad
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.clicks DESC
LIMIT 30

Try this query in the builder →

Use ad IDs to investigate creative performance under comparable targeting and delivery conditions. Entity status is not policy approval; a disapproval report requires the appropriate policy summary fields from the resource reference.

10. Shopping product performance

SELECT segments.product_item_id, segments.product_title,
metrics.clicks, metrics.cost_micros, metrics.conversions_value
FROM shopping_performance_view
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.conversions_value DESC
LIMIT 30

Try this query in the builder →

Product reports help identify high-value products, weak returns and inventory-related opportunities. Use Merchant Center identifiers and consider margin, not only revenue. Product-level data may not reconcile exactly to total account performance.

11. Landing page performance

SELECT landing_page_view.unexpanded_final_url, metrics.clicks,
metrics.cost_micros, metrics.conversions
FROM landing_page_view
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.clicks DESC
LIMIT 30

Try this query in the builder →

Combine landing-page reports with analytics and behavioral evidence to investigate friction. Distinguish expanded and unexpanded URLs, and differences in ads versus analytics attribution.

12. ROAS and cost per acquisition

SELECT campaign.name, metrics.cost_micros, metrics.conversions,
metrics.cost_per_conversion, metrics.conversions_value,
metrics.conversions_value_per_cost
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
ORDER BY metrics.conversions_value DESC
LIMIT 20

Try this query in the builder →

Conversion value per cost is reported ROAS when values represent revenue. If values represent leads or proxy scores, interpret the ratio accordingly. Verify value tracking and CRM outcomes before using it as a profitability measure.

For the formula, attribution and break-even analysis, see our guide to ROAS.

How to Run GAQL in Google Ads Scripts and the API

AdsApp.report() and AdsApp.search()

Both Ads Scripts methods accept GAQL. Report returns flattened rows and is convenient for spreadsheet exports. Search returns nested GoogleAdsRow objects using lowerCamelCase names. Use search for programmatic processing when the flat representation does not expose your fields.

function main() {
const q = 'SELECT campaign.id, campaign.name, metrics.clicks ' +
'FROM campaign WHERE segments.date DURING LAST_7_DAYS';
const rows = AdsApp.search(q);
while (rows.hasNext()) {
const row = rows.next();
Logger.log(row.campaign.name + ': ' + row.metrics.clicks);
}
}

For Sheets use AdsApp.report(query).exportToSheet(sheet) with an authorized spreadsheet. Test read-only scripts in accounts you have permission to access. Log the date and avoid overwriting the last successful report before the new one completes.

Google Ads API: Search and SearchStream

Method

Best fit

GoogleAdsService.Search

Paginated reporting

GoogleAdsService.SearchStream

Streaming large result sets

AdsApp.report()

Flat exports and Sheets

AdsApp.search()

Nested objects in scripts

Live API reporting requires authorization, a developer token, customer ID and any required manager-account context. The playground makes no requests to Google Ads and asks for no credentials. Learn the query structure here before connecting authorized infrastructure.

Automate Daily PPC Operations with GAQL

Workflow

Query input

Human decision

Daily dashboard

Campaign/date/cost/conversions

Interpret results against goals

Budget pacing

Daily spend

Flag over/underspend

Search term review

Term, cost, conversions

Approve negatives and ideas

Creative analysis

Ad ID and performance

Prioritize tests

MCC reporting

Account ID and separate queries

Normalize currency, time zone and goals

Separate extraction, analysis and action. First retrieve consistent raw data. Then apply business rules and surface an explanation of each issue. Finally, use controlled approval for changes. Record run time, customer ID, currency, API version and reporting period. Do not combine different currencies or conversion goals without deliberate transformation.

Explore our data and advanced reporting services for measurement architecture and reporting automation.

Common GAQL Errors and How to Fix Them

Symptom

Likely cause

Fix

Unknown field

Typo or version mismatch

Check version-specific metadata

Incompatible fields

Resource/metric/segment conflict

Remove fields and validate

Date error

Invalid or unbounded date filter

Use supported range and grain

No rows

Filters, zero metrics or availability

Broaden query

Unexpected rows

Added segment or implicit segmentation

Compare grain and IDs

Unknown operator

Unsupported SQL operator

Use GAQL grammar

Reduce a failing query to SELECT campaign.id FROM campaign, then add fields and clauses one at a time. A valid field can still be incompatible with another field for the selected resource. Use the official validator for production, especially when changing API versions.

Why GAQL Results May Differ from the Google Ads UI

Granularity, zero metrics and hidden rows

Match the account, date range, status filters and report view. Segmented reports omit rows where all selected metrics are zero. Search term views may exclude low-volume searches, so totals calculated from visible terms may differ from all campaign traffic.

Conversion timing, attribution and currency

Conversions can be attributed to interaction dates or conversion dates depending on the metric. Conversions arriving later may change yesterday’s numbers. Match conversion action scope, attribution settings, time zone and units. Use unrounded raw values for calculations and format only for presentation.

GAQL Best Practices

Select only necessary fields. Include stable IDs, explicit date ranges and a clear reporting grain. Avoid LIMIT for complete production extraction. Use a consistent API version, review release notes and maintain regression queries. For scheduled reports, implement appropriate retries, pagination or streaming, record failures, and account for conversion lag before raising an alert.

Frequently Asked Questions

Is GAQL the same as SQL?

No. It resembles SELECT syntax, but does not provide arbitrary joins, GROUP BY or aggregate expressions. The resource controls field availability and report grain.

Can I use GAQL without Google Ads API access?

Yes, for learning and validation. Use this playground and Google’s official builder. Live account reporting requires appropriate authorization.

Can GAQL update Google Ads campaigns?

No. GAQL is a reporting language. Use authorized API mutation operations or the applicable script methods for changes.

Does GAQL support OR, JOIN and GROUP BY?

No general OR, JOIN or GROUP BY clauses are supported. Use IN for suitable same-field alternatives, attributed resources for relationships and segments for reporting granularity.

How do I retrieve Performance Max search terms?

Use campaign_search_term_view, a Performance Max campaign filter and compatible fields. search_term_view excludes PMax. Category insights use separate resources.

Can AI write GAQL queries?

AI can draft queries and explain errors, but may invent fields or combine incompatible metrics. Check the target version, validate, compare with a trusted report and retain human review for account changes.

Official Resources and Further Reading

Google Ads API: Query structure

GAQL grammar

Query cookbook

Date ranges

Reporting segmentation

Zero metrics

Performance Max reporting

Google Ads Scripts: Reporting

Want to turn reporting patterns into reliable agency workflows? Explore turnalar’s performance marketing and AI automation services. Start with a reporting question, validate the data, then decide where automation can save time without sacrificing accountability.

For repeatable, reviewed workflows, explore our AI automation services.

See how we support performance marketing and campaign optimization across paid media channels.

About author

Eren turns performance data into smarter growth decisions. He blends paid media, testing, and strategy to help brands scale efficiently, uncover new opportunities, and get more from every campaign.

Eren Korkmaz, Head of Growth at turnalar

Eren Korkmaz

Head of Growth

Subscribe to our newsletter

Sign up to get the most recent blog articles in your email every week.

Related Articles

Keep the momentum going with more blogs full of ideas, advice, and inspiration

Sometimes the hardest part is reaching out but once you do, we’ll make the rest easy.

Address

Office 54687-01 Building A1 Dubai Digital Park, Silicon Oasis

Opening Hours

24/7

No time for rest

9:06:31 AM+00.00

Sometimes the hardest part is reaching out but once you do, we’ll make the rest easy.

Address

Office 54687-01 Building A1 Dubai Digital Park, Silicon Oasis

Opening Hours

24/7

No time for rest

9:06:31 AM+00.00

Sometimes the hardest part is reaching out but once you do, we’ll make the rest easy.

Address

Office 54687-01 Building A1 Dubai Digital Park, Silicon Oasis

Opening Hours

24/7

No time for rest

9:06:31 AM+00.00