google_ads_query
Executes GAQL queries against Google Ads customer accounts to retrieve campaign, ad group, keyword, and performance data.
Instructions
Run a GAQL (Google Ads Query Language) query against a specific customer account.
GAQL is SQL-like: SELECT ... FROM <single_resource> WHERE ... ORDER BY ... LIMIT ....
No JOINs; attribute fields from related resources by selecting them directly.
Common resources: campaign, ad_group, keyword_view, search_term_view,
shopping_performance_view, customer, customer_client, conversion_action,
change_event, change_status, recommendation, asset, asset_group.
Use google_ads_describe_resource first if unsure of field names on a new resource; saves a FIELD_NOT_FOUND roundtrip.
Args: customer_id: 10-digit customer_id (no hyphens) for the account to query. gaql: the full GAQL query string (must start with SELECT; no semicolons). max_rows: if set, stop streaming after this many rows. Defaults to unbounded (the 64 MB response cap still applies). convert_micros: if True (default), also emit _units alongside any _micros field (divided by 1,000,000). E.g. cost_micros = 12345678 → cost_units = 12.345678.
Example queries:
SELECT campaign.id, campaign.name, metrics.cost_micros FROM campaign WHERE segments.date DURING LAST_7_DAYS ORDER BY metrics.cost_micros DESC LIMIT 50
SELECT ad_group.name, ad_group_criterion.keyword.text, metrics.impressions, metrics.clicks FROM keyword_view WHERE segments.date DURING LAST_30_DAYS
SELECT segments.product_item_id, metrics.conversions_value FROM shopping_performance_view WHERE segments.date DURING LAST_30_DAYS
Gotchas (surface to user where relevant):
metrics.cost_micros: 1 unit = $0.000001. Divide by 1M for currency.
LAST_30_DAYS = 30 days ending YESTERDAY (today excluded).
Last 72h data is partial; conversions retroactively re-attribute.
Zero-metric rows are excluded when segmenting by date.
Response cap is 64 MB per call; split by date range for huge reports.
GAQL
IN (...)clause is capped at 20,000 items.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gaql | Yes | ||
| max_rows | No | ||
| customer_id | Yes | ||
| convert_micros | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |