SCALIX help

← All tools

gads_add_location_targeting

Google Ads write medium risk

Part of the Geo Targeting Agent.

What it does

Add geographic (location) targeting criteria to a campaign by geo target constant criterion ID (countries, regions, cities, postal codes, DMAs). Accepts one or more location IDs and an optional per-location bid_modifier; can add NEGATIVE (excluded) locations via negative=true. Returns the created campaign_criterion resource_names plus a plain-English summary of what is now targeted/excluded. Preview->approve->commit: every operation first runs validate_only=true (CampaignCriterionService.MutateCampaignCriteria) producing a diff (campaign, +included / -excluded location NAMES resolved from the geo target constant, bid modifiers; when an included location is in the EU, the campaign's EU political-ads declaration, read from the campaign), waits for explicit user approval, then re-runs validate_only=false with partial_failure=true; the commit is written to the immutable audit log with timestamp. Always run gads_search_geo_locations first to turn place names into criterion IDs — never guess an ID. Accuracy: bid_modifier is a multiplier (1.10 = +10%), NOT micros; location names are resolved from geo_target_constant for the diff so the user approves human-readable places, not numbers; included locations UNION (not intersect) with any existing geo criteria. 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

Use when the user explicitly wants to add or exclude where a campaign serves (e.g. 'target California and exclude Nevada'). Always resolve names->IDs with gads_search_geo_locations first, preview the resolved place names with validate_only, and get a yes before committing — wrong geo silently misspends real budget.

Inputs

NameTypeRequiredDescription
customer_idstringyes10-digit Google Ads CID; strip dashes/spaces before sending (123-456-7890 -> 1234567890). Tenant context is server-derived and must match.
campaign_idstringyesNumeric campaign ID the location criterion attaches to.
location_idsarray<string|int>yesGeo target constant criterion IDs (e.g. 2840 = US, 1014044 = New York). Obtain via gads_search_geo_locations. Each becomes campaign_criterion.location.geo_target_constant = 'geoTargetConstants/{id}'.
negativebooleannoIf true, locations are EXCLUDED (campaign_criterion.negative=true). Default false (included). bid_modifier is not allowed on negative criteria.
bid_modifiernumbernoOptional multiplier for included locations, 0.1-10.0 (1.0 = no change, 1.20 = +20%). Not micros. Omit for no adjustment; not valid with negative=true or on Smart/PMax campaigns.
validate_onlybooleannoOptional. 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_idstringnoOmit 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

Location targeting must not be used to circumvent restricted-vertical geo-gating or a disapproval (e.g. re-running a disapproved ad in a new region to dodge review = Circumventing Systems, an egregious immediate-suspension violation). Apply only the locations the user approved.

Reminder

Resolve every location ID to a human-readable place in the preview; never store or expose account geo data beyond this request.

Errors

Error classMeansWhat to doRetry
CUSTOMER_NOT_FOUNDCustomer ID not found or not linked to this connection.Verify the CID (dashes stripped) and that the user authorized this account; prompt re-auth if the link is stale.no
TOKEN_REVOKEDGoogle authorization was revoked or the refresh token expired.Trigger re-auth (needs_reauth); do not retry with the dead token.no
INVALID_GEO_TARGET_CONSTANTOne or more location IDs are not valid geo target constants.Surface the offending ID; re-resolve via gads_search_geo_locations. Do not guess a substitute ID.no
INVALID_ARGUMENTOperation rejected (e.g. bid_modifier out of range, or bid_modifier set on a negative criterion).Surface the exact platform fieldPathElements/message; fix the input — do not auto-adjust.no
OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPEThis campaign type (e.g. PMax/Smart) does not accept this location criterion or bid modifier.Tell the user the campaign type's restriction; branch on advertising_channel_type before retry.no
PERMISSION_DENIEDBearer token lacks scope or the user's Ads role cannot edit this campaign.Report missing scope / read-only role; do not retry.no
MANAGER_ACCOUNT_WRITETarget CID is a manager (MCC) account; criteria attach to serving accounts, not managers.Ask the user which child serving account to target.no
RESOURCE_EXHAUSTEDRate/quota limit hit (HTTP 429).Exponential backoff 5->10->20s capped 60s, honor retryDelay, then retry.yes
PARTIAL_FAILURESome location operations failed while others succeeded.Report per-operation results; surface each failed location's message; offer to retry only the failures.no
PLATFORM_UNAVAILABLEGoogle Ads API returned a 5xx / INTERNAL / DEADLINE_EXCEEDED.Retry idempotently with backoff; if persistent, report and stop.yes

Edge cases

  • A campaign may carry many location criteria but only ONE proximity criterion — adding proximity is a separate tool; the two coexist.
  • Empty location_ids -> success:false with a clear 'no locations supplied' message (no-op, do not call the API).
  • bid_modifier on a negative location is invalid -> reject before the API call.
  • Adding a location that already exists may surface a duplicate/exists error under partial_failure -> report as already-targeted, not a hard fail.
  • Included locations UNION with existing geo targets (do not intersect) -> widening reach; state in preview.
  • Expired access token mid-call -> refresh once and retry the same idempotent mutate.
  • Preview TTL: if the user approves after the cached preview expired, re-run validate_only before committing.
  • Bid modifiers are unsupported on some channel types (PMax/Smart) -> surface OPERATION_NOT_PERMITTED rather than silently dropping.