Skip to main content
An A/B test serves different ad configurations during the same period and compares their performance. In A2, you can divide an AdUnit’s users into buckets and configure each bucket’s line items and selection method. A bucket is a group containing a configuration to compare. For example, assign different line items to two buckets with a user proportion of 1:1, then compare CTR or cost per conversion.
This page covers experiments comparing line item configurations within A2. Before splitting requests between your existing system and A2, separately define routing and how results from both systems will be compared.

Before you begin

  • API access: Prepare the API address and access token. Reading experiments and metrics requires experiment read permission; creating, updating, and deleting requires write permission.
  • Target and line items: Work with your operator to prepare the AdUnit and line items to compare, and obtain their IDs. Confirm that the line items can serve on that AdUnit. See Core concepts for terminology and relationships.
  • User IDs: Consistently send the same user’s ID in ad requests. See the Ad Request API for request fields.
  • Data delivery: Check the Product Catalog, User Activity Logs, and Ad Event Tracking.
For configuration in Ad Manager, see A/B experiment operations.

Define the comparison

Agree on these points with your operator before creating an experiment. To compare CTR, record impressions and clicks under the same conditions in both buckets. To compare CPA, use the same conversion definition and confirm that costs are recorded. To compare sales, also send conversion_data.sales with conversions. The primary metric is an evaluation criterion. Do not add a separate KPI field to the experiment creation request.

Data needed for each metric

Compare the same AdUnit and period, keeping other conditions stable. Record configuration change times so results before and after a change can be distinguished.

User assignment

A2 determines the bucket using the experiment ID and the ad request’s user ID. With the same bucket configuration, the same user is assigned to the same bucket. Do not implement per-request random bucket selection.
  • Keep the same user’s ID consistent across requests.
  • Requests without a user ID do not receive a bucket assignment. Experiment line items can participate in the regular ad auction and serve, but these requests are not included in experiment bucket metrics.
  • Changing bucket proportions or configuration during an experiment can change assignments. Record what changed and when.
  • line_item_rotate: "random" controls line item selection within an assigned bucket. It is separate from user bucket assignment.
proportion is a relative weight. 1:1 assigns equal proportions of users to two buckets; it does not guarantee equal impression or click counts.

Configuration fields

Experiment

Bucket buckets[]

Include these values for each line item. For advanced settings such as bucket gating, gating_policy, and line item gating, see the Create Experiment API schema. Keep conditions other than those being compared consistent.

Create an experiment through the API

1

Prepare the request body

Save the following as experiment-create.json. Replace the AdUnit ID, two line item IDs, name, and period with your values. Omit the experiment ID and bucket IDs when creating.
2

Create the experiment

Call the creation API. Retain the experiment id and buckets[].id from the HTTP 201 response. The new experiment is inactive.
3

Review the configuration

Use the read API to verify the target, period, line items, and proportions before starting.
experiment-create.json
Replace <experiment_id> with the experiment ID from the response.
API Reference: Create · Get · List

Start and complete an experiment

States follow inactive → active → completed. An experiment applies only when it is active and the current time is within its configured period. Only one active experiment can exist for the same target: the combination of target_type and target_id. An AdUnit experiment and an experiment on its parent Placement can be active simultaneously because their targets differ. If multiple experiments apply to the same request, A2 applies only the one with the smallest experiment UUID. Check for overlapping parent Placement experiments before comparing traffic. The update API accepts the full configuration. Include the name, target, period, and all buckets along with status. The following starts the previous experiment if A2 returned bucket IDs 1 and 2. Replace these with the IDs and settings from your response.
experiment-update.json
  • Complete: Read the latest configuration, change status to completed, and send the full configuration. Once the end time passes, the experiment no longer applies to traffic, but its status does not automatically change to completed.
  • Restart: A completed experiment cannot restart. Create a new experiment for a new comparison.
  • Update buckets: Keep existing bucket IDs. To delete a bucket, retain it in the request with is_deleted: true. Omit the ID for a new bucket. At most 15 bucket IDs can be issued over an experiment’s lifetime, including deleted IDs.
  • Delete experiments: Only inactive experiments can be deleted. The deletion API returns HTTP 204 on success.
API Reference: Update · Delete

Verify experiment application

After saving the configuration, inspect assignment information in actual service responses that return an ad. Consistently include the same user’s ID. If no ad is returned, check the no-ad settings in Ad Serving (Advanced) first. Verify stable assignment for the same user, experiment, and bucket configuration. See the Ad Request API for the response schema. If assignment information is missing, check the user ID, status, period, and target. If a different experiment ID appears, check overlapping AdUnit and parent Placement experiments. These fields confirm the assigned experiment and bucket. They do not prove the selected ad or final impression, click, and conversion aggregates; also compare the bucket metrics below. Additional verification requests record impressions under on_ad_response, so use actual service request records.

Query results

Use the Experiment Bucket Metrics API to compare buckets over the same period. Save the following as experiment-metrics.json and replace the experiment ID and period.
experiment-metrics.json
In the response, total contains each bucket’s totals for the query period. timeseries contains metrics by time interval and line item breakdowns. Match bucket_id to the bucket IDs in the experiment configuration.
Derived metrics return 0 when the denominator is 0. Do not interpret a CPA of 0 as good performance when conversions or costs have not been collected. Verify cost recording and conversion delivery before comparing CPA.
Conversions can occur later than impressions and clicks, so check conversion occurrence times alongside the query period. Do not interpret bucket metrics as lifetime outcomes for every user exposed during the experiment. If conversions occurring outside the experiment period must be measured, separately verify whether they are included in the original experiment metrics. Compare the primary metric chosen before the experiment alongside impressions, clicks, conversions, and bucket proportions for the same period. A2 does not calculate statistical significance or automatically choose a winning bucket. Use the results to decide the next configuration and rollout scope.

If the experiment is not applied

  • Confirm the status is active and the current time is within the period.
  • Match the requested AdUnit ID to the experiment’s target_id.
  • Confirm that ad requests include a user ID. Without one, experiment line items can serve through the regular auction, but the requests are not included in bucket metrics.
  • Check for overlapping experiments on the AdUnit and its parent Placement. Only the applicable experiment with the smallest UUID is applied.
  • Check bucket proportions, line items, and serving conditions for the AdUnit.
  • If metrics are empty, check the query period, timezone, and Ad Event Tracking. A successful configuration lookup does not prove the experiment was applied to traffic or that metrics were collected.
Also check data delivery in Verification and Troubleshooting.