All posts
Google Ads

GAQL Explained for Marketers: Let AI Write Your Queries

Philip Mohr · Co-Founder & COO

· 14 min read

GAQL Explained for Marketers: Let AI Write Your Queries

GAQL, the Google Ads Query Language, is how every report leaves the Google Ads API. Most marketers will never need to type a line of it. You do need to read it, though. When an AI assistant answers a question about your account, a GAQL query did the work, and that query decides whether the answer is right.

The short answer: let AI write GAQL, but learn to check it

AI writes good GAQL. In our run on a live account, Claude turned two plain-English questions into valid queries on the first try. The hard part is judgment: one of those queries flagged 83% of visible search-term spend as "zero conversions," and most of it was not waste. Read this guide to learn the five rules that matter, the safest ways to let AI query your account, and where it still needs you.

What is GAQL?

GAQL (Google Ads Query Language) is the SQL-like language you use to request data from the Google Ads API. Each query names one resource, such as campaign or ad_group, and lists the fields you want back. Google's GAQL overview describes two services that accept it. GoogleAdsService returns account data through Search or SearchStream. GoogleAdsFieldService returns metadata about which fields exist.

GAQL matters to marketers for one reason: it sits under almost every tool that reads Google Ads data. Google Ads scripts use it. Reporting connectors use it. Every Google Ads MCP server uses it, including Google's own. When you ask Claude or ChatGPT "how did my campaigns do last month?", the assistant writes GAQL behind the scenes.

GAQL is a read language. A query returns rows and cannot change a bid, a budget or a campaign. Changes go through separate mutate calls in the API.

How a GAQL query is built

A GAQL query is a short sentence in a fixed order: what you want, from where, under which conditions. Here is a simple one, close to the first query in our worked example below.

Copy
sql
SELECT campaign.name, metrics.cost_micros, metrics.clicks, metrics.conversions FROM campaign WHERE segments.date DURING LAST_30_DAYS ORDER BY metrics.cost_micros DESC LIMIT 10

The clauses, in order

GAQL has six clauses, and only SELECT and FROM are needed for account data. The GAQL grammar page lists them in this order.

ClauseRequired?What it does
SELECTYesLists the fields to return, separated by commas
FROMYes, for account dataNames the one resource the query is about
WHERENoFilters rows, with conditions joined by AND
ORDER BYNoSorts the rows
LIMITNoCaps the number of rows
PARAMETERSNoSets options, such as including drafts

Resources, attributes, segments and metrics

Every field in a GAQL query belongs to one of four groups. Once you see the groups, most queries become readable.

  • Resource: the thing you are asking about, such as campaign, ad_group or search_term_view. It goes in FROM.
  • Attribute: a fact about a resource, such as campaign.name or campaign.status.
  • Segment: a way to split the data, such as segments.date or segments.device. Each segment you add splits the results into more rows.
  • Metric: a performance number, such as metrics.clicks or metrics.conversions.

A metric is always reported per segment you select. Ask for clicks by device and you get one row per device, each with its own click count.

GAQL has no JOIN. You pull fields from a related resource by naming them, and Google calls that an attributed resource. A query FROM ad_group can still select campaign.name, because every ad group belongs to a campaign.

Five rules that trip marketers up

Five GAQL rules cause most of the broken queries we see, whether a human or an AI wrote them.

1. Cost comes in micros. metrics.cost_micros is the cost times one million, so £12.88 comes back as 12,880,000. Google's Money reference says one million micros equals one currency unit. 2. DURING takes only preset ranges. DURING LAST_30_DAYS works. DURING '2026-11-01' does not. Custom dates use BETWEEN with YYYY-MM-DD dates, per the date ranges guide. 3. There is no OR. The grammar only joins conditions with AND. Use IN or REGEXP_MATCH when you want "this or that." 4. Dates follow the account's time zone. A London account and a Toronto account cut "yesterday" at different hours. 5. Segments multiply rows. Add segments.date to a 30-day query and one campaign row becomes 30 rows.

Ten marketer questions and the GAQL resource that answers each

The fastest way to understand GAQL is to map the questions you already ask to the resource that answers them. Google's query cookbook pairs many of these resources with the Google Ads screens you know.

Your questionFROM resourceKey fields
How did my campaigns do last month?campaignmetrics.cost_micros, metrics.conversions
Which search terms cost money and never converted?search_term_viewsearch_term_view.search_term, metrics.cost_micros
Which keywords have a low Quality Score?keyword_viewad_group_criterion.quality_info.quality_score
Am I losing impressions to budget or to rank?campaignmetrics.search_budget_lost_impression_share
Which ads perform best?ad_group_adad_group_ad.ad.id, metrics.ctr
Which landing pages convert?landing_page_viewlanding_page_view.unexpanded_final_url
How do mobile and desktop compare?campaignsegments.device, metrics.conversions
Which conversion actions are counting?conversion_actionconversion_action.name, conversion_action.status
What changed in the account this week?change_eventchange_event.change_date_time
How are my Shopping products doing?shopping_performance_viewsegments.product_item_id, metrics.conversions_value

The change_event row has a catch. Google's change event guide only allows a date range within the past 30 days. The query also needs a LIMIT of 10,000 rows or fewer. An AI that skips either gets an error, not an answer.

Four ways to get GAQL written for you

GAQL can come from a point-and-click tool, a developer plugin, a chatbot or an MCP server. The right pick depends on whether you want to run the query or only see it. We build one of these options, so weigh our verdicts with that in mind. The Model Context Protocol (MCP) is an open standard, introduced by Anthropic in 2024, that lets AI assistants such as Claude and ChatGPT connect to outside tools and data through MCP servers.

ApproachSetupWho writes the GAQLRuns on live dataCostBest for
Google Ads Query BuilderNoneYou, by clickingNoFreeLearning the syntax
Google Ads API Developer AssistantPython, Git, a CLI, a Cloud project, API credentialsAIYesFree, plus your AI planDevelopers
Chatbot with no connectionNoneAINoYour AI planOne-off drafts you run elsewhere
Google's official Google Ads MCP serverPython, a Cloud project, OAuth credentialsAIYes; reads, plus limited asset and label editsFree, self-hostedTeams with a developer
HYPD (managed MCP server)Google sign-inAIYes, read-only by defaultFree for 1 account, then from $19.99/monthMarketers who will not open a terminal

Verdict: the best way to learn GAQL, and no way to run it. Google's Query Builder lets you pick a resource and tick the fields, and it only offers fields that work together. A companion Query Validator checks a query you paste in. You still need somewhere to run the result. Spend 20 minutes here if you want to read AI-written queries with confidence.

Verdict: strong, and built for developers. Google's Developer Assistant is an open-source plugin for Claude Code and Google's Antigravity CLI. It turns a plain-English request into GAQL, validates it and runs it against your account. It never runs changes; it saves them as code for you to run. Setup needs Python 3.10 or later, a Google Cloud project and a google-ads.yaml credentials file. Google's page also says enabling the API grants only Test access, and production accounts need a higher access level.

A chatbot with no connection

Verdict: fine for a draft, risky as a habit. ChatGPT and Claude both write passable GAQL from a description. Without a live connection, though, the model cannot check field names against your API version or see your data. You copy the query somewhere else to run it. The temptation is to paste the results back into a consumer chat, client data included. That is the habit to avoid.

Google's official Google Ads MCP server

Verdict: the best deal if you have a developer. Google's Google Ads MCP server is free and open source. Since v0.0.6 it can also edit assets and labels, with a confirm step, but it cannot change campaigns, budgets or bids. Its search tool runs GAQL, and a metadata tool lets the AI check field names first. You host it yourself in Python, with a Google Cloud project and OAuth credentials. For a team with an engineer, that is a fair trade for a free tool. Our comparison of Google Ads MCP servers covers the rest of the field.

HYPD

Verdict: the shortest path for a marketer, at a price. HYPD is the AI co-pilot for performance marketers: it connects Google Ads, Meta Ads, GA4, Merchant Center, Search Console, Microsoft Ads and LinkedIn Ads to Claude and ChatGPT through MCP, read-only by default, EU-hosted and GDPR-compliant. You sign in with Google, with no Cloud project or OAuth setup of your own. HYPD's Google Ads MCP runs the GAQL the assistant writes and returns cost in the account currency instead of micros. It loses two rows to Google's server: you cannot self-host it, and past one account it costs money.

Worked example: one question, the GAQL Claude wrote, the real result

We asked two questions on a live Google Ads account and kept the queries exactly as written. The account belongs to a Canadian exam-prep business one of our team runs on the side. The run was on December 2, 2026, in Claude through the HYPD MCP server. Figures are rounded, in GBP, and cover the last 30 days.

How did each campaign do in the last 30 days? Show spend, clicks, conversions and cost per conversion.

Claude wrote this query and ran it with HYPD's GAQL tool:

Copy
sql
SELECT campaign.name, campaign.status, metrics.cost_micros, metrics.clicks, metrics.conversions, metrics.cost_per_conversion FROM campaign WHERE segments.date DURING LAST_30_DAYS AND metrics.impressions > 0 ORDER BY metrics.cost_micros DESC
CampaignStatusSpendClicksConversionsCost per conversion
Homepage landingEnabled£42656533£12.88
Course-specific landing pagesPaused£2582248.5£30.40

The follow-up question went one level deeper.

Which search terms spent money in the last 30 days without converting?

Claude queried search_term_view with the same DURING LAST_30_DAYS date range and a metrics.cost_micros > 0 filter. The query came back with 140 search terms and £235 of spend. Of those terms, 123 had zero conversions, worth £196. That is 83% of the visible search-term spend.

The query was correct, and the headline is misleading. Most of those 123 terms got one or two clicks each, and nearly all were close variants of searches that do convert. That is thin data, not waste. Adding them as negative keywords would have cut traffic the account needs. The click counts were right there in the rows. A summary that leads with the £196 total buries them.

From our tests: the AI got the GAQL right both times. The judgment took a human who knew the business.

Where AI-written GAQL still goes wrong

AI-written GAQL fails less often from bad syntax than from queries that run fine and answer the wrong question. These are the four failure modes we see most.

A valid query with a misleading answer

Quality Score is the classic trap. We asked for Quality Score by day for the last 30 days, and the query ran without an error. Every day showed the same score, because ad_group_criterion.quality_info.quality_score is today's value repeated on each row. Google said as much in 2017, when it added separate historical Quality Score columns. The API equivalent is metrics.historical_quality_score. An AI that picks the first field will chart a trend that never happened.

Data that the query cannot see

Search-term queries miss part of your spend, and nothing in the result says so. In our run, the visible search terms covered £235 of £684 in campaign spend, about 34%. Google leaves low-volume search terms out of the report to protect user privacy. An AI that sums the rows and calls it "your search-term spend" is wrong by two-thirds.

Field names that change between versions

GAQL syntax stays put while the field catalog moves. Google's overview says the syntax is the same from API v23 to v26, but the queryable fields differ by version. A chatbot trained on older docs will name fields that no longer exist. Connected tools avoid most of this by checking against GoogleAdsFieldService or returning the API's error so the model can retry.

The judgment call

Numbers do not tell you what to do. The £196 in "zero-conversion" search terms above is the clearest example we have. AI is fast at finding the rows. Deciding which rows matter still takes someone who knows the margins, the season and the customer.

Is it safe to let AI run GAQL on your Google Ads account?

Running GAQL on its own is safe, because a GAQL query can only read data. The risk sits in the connection, not the query: who holds the access token, what else it allows and what happens to the rows afterward.

The catch is OAuth. Google offers one permission scope for Google Ads, and its consent screen says the app can "see, edit, create and delete" your data. HYPD's setup guide for Claude explains that HYPD reads by default, whatever that screen says. Read-only tools, GAQL queries included, run on their own. Write access is switched on per account and per platform. Once it is on, the AI drafts a change and nothing runs until a human approves it. Every approved change is logged and can be reverted.

If you manage client accounts, one extra rule applies: keep each client in a separate chat. Our agency guide to connecting Google Ads safely covers permissions and audit trails in more detail. In our experience, mixing two clients' rows in one conversation is the easiest way to leak data with AI. If the account is your own store, the same advice still holds for anything with customer data in it.

So, should you learn GAQL?

Learn to read GAQL, and let AI write it. One afternoon with the five rules above and the Query Builder is enough. After that, you will spot a wrong date range, a micros mix-up or a field that answers a different question. If you have a developer, Google's free MCP server gives you live GAQL in Claude or ChatGPT. If you do not, a managed MCP server such as HYPD gets you there with a Google sign-in, and the first account is free. Either way, keep the final call on what to change.

Connect your Google Ads account read-only on the free plan and ask your first question in plain English.

FAQ

Bring paid media into your AI, safely.