gads_get_ad_group
Google Ads read low risk
Part of the Google Ads Manager Agent.
What it does
Fetch a single ad group's configuration and (optionally) its performance via GoogleAdsService.SearchStream with a GAQL query against the ad_group resource. Returns ad_group.id, name, status, type, cpc_bid_micros/cpm_bid_micros, campaign, and effective targeting settings; when metrics are requested it also returns impressions, clicks, ctr, average_cpc, cost_micros, conversions, conversions_value over the supplied date range plus the prior_period deltas via include_prior_period=true. Accuracy: cost/bid fields are micros (divide by 1e6, label currency); ctr/average_cpc are ratios/micros already computed by the API — do not recompute from rounded values; if a segment (e.g. segments.date or segments.device) is included, metric rows multiply per segment and must be summed for totals; metrics must reconcile to the Google Ads UI within +/-1%; never fabricate a value not returned by the API.
When to use it
When the user asks about ONE specific ad group — its settings, status, bids, or metrics. For all ad groups at once use gads_list_ad_groups.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
ad_group_id | string | yes | Numeric ad group id; combined with customer_id to form the resource name. Dashes stripped from any CID. |
customer_id | string | yes | 10-digit account CID, dashes stripped. |
include_metrics | boolean | no | If true, add metrics.* and a date range (defaults to LAST_30_DAYS) and compute prior-period delta. |
date_range | string | no | GAQL date macro (LAST_7_DAYS, LAST_30_DAYS, THIS_MONTH...) or explicit 'YYYY-MM-DD' AND 'YYYY-MM-DD'. Only used when include_metrics=true. |
include_prior_period | boolean | no | Opt-in: also run the equal-length preceding window and attach prior_period={date_range, metrics, delta_pct} to every row. Needs a translatable date_range (LAST_7/14/30_DAYS, TODAY, YESTERDAY, THIS_MONTH, LAST_MONTH, or explicit 'YYYY-MM-DD,YYYY-MM-DD'); untranslatable ranges skip with a warning. |
Safeguards
Policy
Read-only; ad group metrics must reconcile to the Google Ads UI within +/-1% for the same date range and timezone. Do not present a computed estimate as a platform-reported figure; if a value cannot be reconciled, say so.
Reminder
Do not retain or expose ad group data beyond the current request; enforce per-account isolation (server-derived tenant context + Postgres RLS).
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
CUSTOMER_NOT_FOUND | The customer ID was not found or is not authorized for this user. | Verify the CID and authorization; re-auth if revoked. | no |
TOKEN_REVOKED | OAuth credential revoked/expired and unrefreshable. | Prompt reconnect (needs_reauth). | no |
INVALID_ARGUMENT | GAQL was rejected (bad field, malformed date) — surfacing Google's message. | Surface the exact GAQL error; fix the query, do not guess field names. | no |
PERMISSION_DENIED | Bearer scope or account role does not permit reading this account. | Confirm adwords scope and account access; the requested CID may be outside the bearer scope. | no |
RESOURCE_EXHAUSTED | Rate/quota exceeded (HTTP 429). | Exponential backoff 5->10->20s cap 60s; honor retryDelay. | yes |
PLATFORM_UNAVAILABLE | Google Ads API 5xx/internal error. | Retry the read after backoff. | yes |
Edge cases
- Ad group id valid but not found -> success:true, count:0, data:null (not an error).
- include_metrics with a segment (date/device) returns multiple rows that must be aggregated for a single total.
- Manager (MCC) account: ad_group metrics are not meaningful at the MCC level — operate on a client account.
- cpc_bid_micros may be null/absent under automated bidding strategies — report 'managed by strategy' rather than 0.
- Date range with no impressions -> metrics return zeros, not an error; report zeros.
- Expired token mid-read -> refresh once and retry the SearchStream.
- Removed ad group still returns config rows with status REMOVED — surface the status, don't treat as missing.