Google Ads GAQL query
gads_queryRun a read-only GAQL SELECT on one Google Ads customer to fetch custom reporting fields outside fixed templates. Use it for tailored campaign, keyword, and performance queries.
Instructions
Run a free read-only Google Ads Query Language (GAQL) SELECT on one customer (searchStream), for fields the fixed gads_performance templates do not cover. Refused without any network call unless it is a single SELECT with no ';' and no '--' or '/' (refused even inside a string literal). The read is bounded: without LIMIT, LIMIT 10001 is added (before PARAMETERS); a larger LIMIT is lowered to 10001; the answer is capped at 20 MB. One SELECT and one FROM only, no JOIN, no backslash, ASCII only outside string literals. FROM and every dotted name prefix in SELECT, WHERE and ORDER BY (besides metrics and segments) must be a reporting resource: customer, campaign, campaign_budget, ad_group, ad_group_ad, ad_group_criterion, keyword_view, shopping_performance_view, product_group_view, asset_group, asset_group_listing_group_filter, asset_group_asset, asset, ad_group_ad_asset_view, campaign_criterion, geographic_view, gender_view, age_range_view, landing_page_view, expanded_landing_page_view, display_keyword_view, topic_view, bidding_strategy, conversion_action, location_view, distance_view, with customer. limited to id, descriptive_name, currency_code, time_zone, status, manager, test_account and resource_name; anything else is refused with resource_not_allowed. Names exposing personal data (change_event, click_view, call_view, search term views, leads, user_*, payments_*, billing_*, customer_user_access, invoices, account links, placements...) are refused anywhere in the query with sensitive_resource. Setting GADS_ALLOW_SENSITIVE_QUERIES=1 in the server env lifts both lists (personal data possible). Rows are flattened to GAQL field names (campaign.name, metrics.clicks); micros fields are converted to currency units: micros renamed without the suffix (metrics.cost_micros -> metrics.cost), metrics.average_cpc, average_cpm, average_cost and cost_per kept under their name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gaql | Yes | One read-only GAQL statement starting with SELECT, e.g. SELECT campaign.name, metrics.clicks FROM campaign WHERE segments.date DURING LAST_7_DAYS; no ';', '--' or '/*' anywhere, even in a string | |
| limit | No | Maximum rows returned (1 to 1000); Google is asked for at most 10,001 rows (LIMIT added or lowered) | |
| client_id | No | Client id from clients_list; empty uses the only client | |
| customer_id | No | Google Ads customer id (digits, dashes allowed), as listed by gads_accounts; empty uses the client's (or GADS_CUSTOMER_ID) |