AWQL vs GAQL: updating old Google Ads scripts
Why older scripts use AWQL report names, how GAQL differs, and how to convert a query.
Scripts written some years ago query data with AWQL, the AdWords Query Language, and report names in capitals such as KEYWORDS_PERFORMANCE_REPORT. Current Google Ads scripts use GAQL. Old queries often still run through a compatibility layer, but new fields and campaign types are only available in GAQL, and mixed scripts are hard to maintain.
The differences
- Reports became resources.
CAMPAIGN_PERFORMANCE_REPORTiscampaign;KEYWORDS_PERFORMANCE_REPORTiskeyword_view;SEARCH_QUERY_PERFORMANCE_REPORTissearch_term_view. - Fields are prefixed.
CampaignNameiscampaign.name;Clicksismetrics.clicks;Dateissegments.date. - Cost is in micros —
metrics.cost_micros. - Dates are an ordinary filter —
segments.date DURING LAST_30_DAYSin theWHEREclause, not a separateDURINGclause at the end.
Before and after
AWQL:
SELECT CampaignName, Clicks, Cost
FROM CAMPAIGN_PERFORMANCE_REPORT
WHERE Impressions > 0
DURING LAST_30_DAYSGAQL:
SELECT campaign.name, metrics.clicks, metrics.cost_micros
FROM campaign
WHERE metrics.impressions > 0
AND segments.date DURING LAST_30_DAYSConverting a script
- Find every query string in the script.
- Replace the report name with the resource and the fields with their GAQL names.
- Move the date range into
WHERE. - Update the code that reads the results: field names changed, and cost now needs dividing by 1,000,000.
- Test each query on its own before running the whole script.
Testing the new queries
Paste each converted query into GAQL Lab. The validator flags unknown fields and fields that do not belong to the resource, and autocomplete suggests the right names. With the Claude connector you can also ask Claude to convert the script and check the queries against a real account.