gads_create_experiment
Google Ads write medium risk
Part of the Experiment Agent.
What it does
Create a campaign experiment (A/B test) via ExperimentService + ExperimentArmService. SCALIX SOP: `hypothesis` and `primary_metric` are REQUIRED — the hypothesis is written to the immutable audit log so the result can be judged later; `min_run_duration_weeks` defaults to the Scalix 4-week minimum and a lower value returns a warning that the result is unlikely to reach significance. traffic_split_percent (1..99) is the treatment arm; the control arm gets the remainder. A suffix is auto-derived when a control campaign is given: Google appends it to the name of the treatment arm's copy of that campaign, and the control keeps its name (v24 Experiment.suffix). Google checks the experiment at preview; the arms are created, and checked, only at commit. PREVIEW (validate_only) -> APPROVE (preview_id) -> COMMIT. Returns {success, data:{applied:{hypothesis, primary_metric, min_run_duration_weeks, control_arm, treatment_arm, experiment, arms}}, warnings}. 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.
When to use it
Setting up an A/B experiment. Ask for the test type, the hypothesis in one sentence, the primary metric (CPA/ROAS/CVR), the traffic split, and the intended run length (>=4 weeks). Do not start a test without a written hypothesis.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
customer_id | string | yes | 10-digit CID; strip dashes. |
name | string | yes | Experiment name. |
experiment_type | string | yes | SEARCH_CUSTOM or DISPLAY_CUSTOM. |
traffic_split_percent | integer | no | 1-99, % of traffic to the treatment arm (default 50). Control gets 100 - this. |
control_campaign_id | string | no | Campaign used as control; Google copies it for the treatment arm. Without it both arms are created with no campaign, and the preview warns. |
description | string | no | Optional description. |
suffix | string | no | Suffix Google appends to the treatment arm's campaign name (its copy of the control campaign; v24 Experiment.suffix). Default when control_campaign_id is given: '[exp <experiment name>]'. |
manager_id | string | no | Optional MCC login-customer-id. |
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. |
hypothesis | string | yes | One-sentence hypothesis the test will prove or disprove. Required; audit-logged. |
primary_metric | string | yes | The single metric that decides the test (e.g. CPA, ROAS, CVR). Required. |
min_run_duration_weeks | integer | no | Intended run length. Scalix minimum is 4; a lower value warns. |
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
Experiments must be a legitimate A/B test, not a way to relaunch disapproved content under a new campaign (Circumventing Systems). Label arms clearly so the treatment isn't mistaken for an evasion of a disapproved original.
Reminder
Use experiments for genuine testing, never to relaunch disapproved content; both arms spend real money once scheduled.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
INVALID_ARGUMENT | Invalid traffic split (not 1-99) or incompatible experiment type for the control campaign. | Surface the platform message; use a 1-99 split and a matching type, then re-preview. | no |
EXPERIMENT_ERROR | Control campaign ineligible for experiments (e.g., PMax, already in an experiment). | Choose an eligible Search/Display campaign; surface the platform message. | no |
TOKEN_REVOKED | OAuth token expired/revoked. | Refresh and retry once; else prompt reconnect (needs_reauth). | yes |
CUSTOMER_NOT_FOUND | Customer ID not found/accessible. | Verify the CID is authorized. | no |
PERMISSION_DENIED | No access or out-of-bearer-scope write. | Confirm access and write scope; else refuse. | no |
RESOURCE_EXHAUSTED | Rate/quota exceeded (HTTP 429). | Backoff 5/10/20s cap 60s, then retry. | yes |
INTERNAL_ERROR | Transient Google server error (5xx). | Retry after backoff. | yes |
Edge cases
- Created at SETUP; no traffic/spend until gads_schedule_experiment runs.
- Without control_campaign_id both arms are created with no campaign -> the preview warns that the experiment has nothing to test yet.
- PMax/some campaign types are ineligible -> EXPERIMENT_ERROR; branch on campaign type.
- traffic_split outside 1-99 rejected.
- Preview creates nothing; preview_id TTL expiry -> re-preview; expired token -> refresh once and retry.