gads_add_campaign_audience
Google Ads write medium risk
Part of the Google Ads Audience Agent.
What it does
Add audiences to a whole campaign: Google's affinity and in-market segments, detailed demographics, your data (user lists) and custom segments; or exclude them with exclude=true. Find Google-made audiences and their ids with gads_search_audiences; for one ad group use gads_attach_audience_to_ad_group. Works on Search and Standard Shopping campaigns; on Display, Google takes campaign-level audiences only as exclusions. Performance Max (audiences go in asset-group signals), Demand Gen (audiences go on ad groups) and Video (Google's API can't change Video campaigns) are refused before any change, naming where to go instead. Targeted audiences run in OBSERVATION (bids and reporting; reach unchanged) or TARGETING (the campaign serves only to its audiences). Default: the campaign's current mode, else OBSERVATION (Google's advice for Search and Shopping); an unset mode counts as TARGETING at Google, so the campaign is set to OBSERVATION explicitly. The campaign's other targeting restrictions are kept. Refused before any change: setting the campaign's audience mode while its ad groups set their own (Google keeps it on the campaign or its ad groups, not both), any targeted audience on Display (add those to its ad groups), other campaign types, an excluded custom segment, a bid modifier on an exclusion, and life events (Google's API refuses them as campaign audiences). Google keeps audiences on the campaign or on its ad groups, not both: when the ad groups already have some, the preview fails with Google's reason and where to add instead. The preview shows each audience's name and the campaign's current and new audience mode, and warns when the result is TARGETING. Each audience becomes one campaign_criterion; any audience-mode change goes in the same atomic request. Returns the created resource_names. PREVIEW SEMANTICS: the first call (no preview_id) is sent to the Google Ads API in validation mode — field, enum, policy and permission errors surface AT PREVIEW, nothing is changed, and the response returns a preview_id. To apply, show the preview to the user, get their approval, and re-call with that preview_id and IDENTICAL arguments within 30 minutes; changed arguments or an expired token fail closed to a fresh preview. validate_only=true forces another preview; validate_only=false alone never commits.
When to use it
When the user wants Google-made audiences (affinity, in-market, detailed demographics), their own lists or custom segments on a whole campaign, or excluded from it; search the ids first with gads_search_audiences. For one ad group use gads_attach_audience_to_ad_group.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
customer_id | string | yes | 10-digit Google Ads CID; strip dashes/spaces before sending (123-456-7890 -> 1234567890). Tenant context is server-derived and must match. |
campaign_id | string | yes | Numeric ID of a Search or Standard Shopping campaign, or of a Display campaign for exclusions. |
audiences | array<object> | yes | Each {type, id} as gads_search_audiences returns it, type one of AFFINITY, IN_MARKET, DETAILED_DEMOGRAPHIC, USER_LIST, CUSTOM_AUDIENCE (USER_INTEREST also accepted); or an audience resource name (customers/{cid}/userInterests/{id}, /userLists/{id}, /customAudiences/{id}, /detailedDemographics/{id}). Duplicates are added once. LIFE_EVENT is refused (Google's API doesn't take it at campaign level). |
exclude | boolean | no | true adds the audiences as exclusions (campaign_criterion.negative). Default false. Custom segments can't be excluded at campaign level. |
targeting_mode | string | no | OBSERVATION or TARGETING, for targeted audiences only. Default: the campaign's current mode, else OBSERVATION. |
bid_modifier | number | no | Multiplier for targeted audiences, 0.1-10.0 (1.2 = +20%). Not valid with exclude=true. |
validate_only | boolean | no | Optional. true forces another preview even with a preview_id; false is DEPRECATED and no longer commits — only a valid preview_id applies the write. |
preview_id | string | no | Omit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview. |
Safeguards
A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.
Policy
Audiences must follow Google's personalized-advertising policy: no sensitive categories, and housing, employment and credit ads in the US and Canada can't target or exclude by age, gender, parental status, marital status or ZIP code. Don't use audiences to work around a disapproval. Every change previews first and applies only after the user approves that preview.
Reminder
Show the audiences by name, the campaign and its audience mode before and after; apply only after the user approves that preview in a new message.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
INVALID_ARGUMENT | A refused audience, campaign type or argument (the message says which and where to go instead). | Fix what the message names and preview again. | no |
NOT_FOUND | The campaign is not in this account. | Check the id with gads_list_campaigns. | no |
CRITERION_ERROR | Google refuses an audience for this campaign at preview (e.g. AUDIENCE_NOT_ELIGIBLE_FOR_CAMPAIGN_TYPE, CANNOT_ATTACH_CRITERIA_AT_CAMPAIGN_AND_ADGROUP, a duplicate). | Report Google's reason; nothing was changed. | no |
TOKEN_REVOKED | Authorization revoked / refresh token expired. | Trigger re-auth (needs_reauth); do not retry with the dead token. | no |
PERMISSION_DENIED | The login cannot access this account. | Report it; check the account with gads_list_accessible_customers. | no |
RESOURCE_EXHAUSTED | Rate/quota limit (HTTP 429). | Backoff 5->10->20s cap 60s, honor retryDelay; retry. | yes |
PLATFORM_UNAVAILABLE | Google Ads 5xx / INTERNAL / DEADLINE_EXCEEDED. | Idempotent retry with backoff. | yes |
Edge cases
- An audience already on the campaign -> Google refuses the duplicate at preview; list the campaign's audiences with gads_list_campaign_criteria.
- The campaign's ad groups already have audiences -> Google refuses at preview (CANNOT_ATTACH_CRITERIA_AT_CAMPAIGN_AND_ADGROUP; checked live on Search 13 Oct); add to those ad groups with gads_attach_audience_to_ad_group, or remove theirs first.
- Detailed demographics use Google's ids from gads_search_audiences (previewed clean on Search 13 Oct); Google decides at preview whether this campaign type takes them.
- Life events -> refused before any change: Google's API refuses them as campaign criteria (OPERATION_NOT_PERMITTED_FOR_CONTEXT on Search and Display, checked 13 Oct).
- Switching a campaign from OBSERVATION to TARGETING narrows who sees the ads -> the preview warns.
- Display: a targeted audience -> refused before any change (Google refuses targeted affinity, in-market and detailed demographics at campaign level there; checked live 13 Oct); add them to the ad groups with gads_attach_audience_to_ad_group, or exclude here.
- Performance Max / Demand Gen / Video -> refused before any change, naming where audiences go instead; other campaign types (e.g. Smart, App, Hotel) are refused too.
- A CLOSED user list -> Google refuses it at preview, exclusions included; pick an OPEN list (gads_list_user_lists).
- Expired token -> refresh once, retry.