gads_set_dynamic_search_ads_setting
Google Ads write medium risk
Part of the Search Campaign Agent.
What it does
Configure a Search campaign's Dynamic Search Ads setting: Campaign.dynamic_search_ads_setting {domain_name, language_code, use_supplied_urls_only}. DSA auto-generates headlines and targets pages from the given domain/feed without keywords. Updates Campaign with update_mask=dynamic_search_ads_setting. Returns the old->new DSA config. Preview->approve->commit: validate_only=true diff (campaign, current DSA setting -> proposed domain/language/feed-only flag, and what will now be auto-targeted), explicit approval, then commit (with preview_id) sends validate_only=false server-side + audit log. Accuracy/safety: domain_name must be the bare domain (no scheme/path, e.g. 'example.com'); language_code is the page language; use_supplied_urls_only=true restricts to your page-feed URLs only. DSA can auto-serve to pages you didn't intend — the preview warns and recommends DSA webpage exclusions/negatives. The preview shows the current DSA setting next to the proposed one and warns that DSA can serve on unintended pages. 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 wants Dynamic Search Ads on a Search campaign (e.g. 'turn on DSA for example.com'). Preview the domain, language, and feed-only flag, and warn that DSA can auto-target unintended pages — recommend DSA webpage exclusions/negatives — before committing.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
customer_id | string | yes | 10-digit CID, dashes/spaces stripped. Tenant context server-derived. |
campaign_id | string | yes | Numeric Search campaign ID (DSA is a Search-campaign feature). |
domain_name | string | yes | Bare domain to dynamically target, no scheme/path (e.g. 'example.com'). Strip https:// and trailing slashes before sending. |
language_code | string | yes | Language of the site pages (e.g. 'en'). Should match the campaign's language targeting. |
use_supplied_urls_only | boolean | no | If true, DSA targets only URLs from your linked page feed (not the whole crawled domain). Default false. Requires a linked page feed if 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
DSA auto-generates ad text and lands on auto-selected pages — those pages and headlines must still meet Google editorial/Misrepresentation policy. Don't enable DSA on a domain whose pages you can't stand behind, and never use it to auto-serve disapproved content (Circumventing Systems).
Reminder
DSA auto-selects landing pages/headlines you don't hand-write; confirm the domain and recommend exclusions; don't retain account data beyond this request.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
CUSTOMER_NOT_FOUND | Customer ID not found or not linked. | Verify CID (dashes stripped); re-auth if stale. | no |
TOKEN_REVOKED | Authorization revoked / refresh token expired. | Trigger re-auth (needs_reauth); do not retry with the dead token. | no |
INVALID_DOMAIN | domain_name includes a scheme/path, is malformed, or isn't verifiable. | Surface the platform message; send the bare domain only. Do not guess a domain. | no |
OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE | DSA setting is only valid on Search campaigns; this campaign isn't Search. | Explain DSA requires a Search campaign; do not retry on other channel types. | no |
MISSING_PAGE_FEED | use_supplied_urls_only=true but no page feed is linked. | Tell the user to attach a page feed first or set the flag false. | no |
INVALID_ARGUMENT | Bad language_code / update_mask. | Surface platform message; fix input. | no |
PERMISSION_DENIED | Missing scope or read-only role. | Report missing scope / role; do not retry. | no |
MANAGER_ACCOUNT_WRITE | Target CID is a manager (MCC) account. | Ask which child serving account to target. | 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
- domain_name pasted with https:// or path -> normalize to bare domain before send.
- language_code mismatched with the campaign's language targeting -> DSA serves poorly; warn in preview.
- use_supplied_urls_only=true without a page feed -> MISSING_PAGE_FEED.
- Enabling DSA still needs a DSA ad group + dynamic_search_ads ad to serve -> note this is the campaign-level setting only.
- DSA may auto-target sensitive/irrelevant pages -> recommend webpage exclusions/negatives in the preview.
- Expired token -> refresh once, retry.
- Preview expired before approval -> re-run validate_only before commit.