Stay organized with collections
Save and categorize content based on your preferences.
The AdMob API can create mediation A/B experiments to maximize your ads
performance by testing various configurations. An A/B test lets you evaluate
two variations of a mediation group to compare the results side by side and
select a preferred configuration.
Here are examples of experiments you can set up:
Adding or removing ad sources to see their impact on your mediation group
Using a different waterfall order by changing the manual eCPM value of ad
sources
Enabling or disabling optimization on waterfall ad sources
Changing the number of times an ad source is called
Examples
Start with an existing mediation group and create a variation of it to see
which variant, A or B, performs better. The test splits your app's users
between your existing mediation group setup and the variation, based on a
percentage (1%, 10%, or 50%) you provide.
The first time you perform this step, you are asked to accept an
authorization prompt in your browser. Before accepting, make sure you're
signed in with a Google Account that has access to the AdMob API. Your
app will be authorized to access data on behalf of whichever account is
currently logged in.
For authentication and authorization, we recommend using
oauth2l, a simple command-line tool for
working with Google OAuth 2.0. Install oauth2l and run the command below,
replacing path_to_credentials_json with a path to a
credentials.json file that you download when registering your cloud
app. For the first run, the command walks you through the OAuth 2.0
authorization flow. Subsequent runs refresh the token automatically.
Replace pub-XXXXXXXXXXXXXXXX with your publisher
ID and ZZZZZZZZZZ with your
mediation group ID. The mediation group ID can be found in the AdMob UI or
by using the
accounts.mediationGroups:list
method.
The following request creates a mediation A/B experiment where the
treatment variant, also known as variant B, contains a single mediation
line for the AdMob network using
LIVE mode.
See the sample response below where SSSSSSSSSSSSSSSSSSSSSS represents
the created mediation A/B experiment ID and YYYYYYYYYY represents the
last 10 digits of your ad unit
ID, complying to the format:
ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY.
The
mediationAbExperimentState
is set to RUNNING for active mediation A/B experiments and NOT_RUNNING
if there is no experiment running in the mediation group.
Stop the mediation A/B experiment and select a variant.
Replace pub-XXXXXXXXXXXXXXXX with your publisher
ID and ZZZZZZZZZZ with your
mediation group ID. The mediation group ID can be found in the AdMob UI or
by using the
accounts.mediationGroups:list
method.
To complete the experiment, specify the winning variant in the request:
VARIANT_CHOICE_A: Use the mediation lines from Variant A and complete
the experiment. Variant A contains the original serving lines before the
experiment creation.
VARIANT_CHOICE_B: Use the mediation lines form Variant B and complete
the experiment. Variant B contains the newly added serving lines.
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe AdMob API enables the creation of mediation A/B experiments to optimize ad performance by comparing different mediation group configurations.\u003c/p\u003e\n"],["\u003cp\u003eYou can test variations like adding/removing ad sources, adjusting waterfall order, enabling/disabling optimization, and modifying ad source call frequency.\u003c/p\u003e\n"],["\u003cp\u003eExperiments split app users between the existing setup and a variation to determine the better performer, with traffic allocation options of 1%, 10%, or 50%.\u003c/p\u003e\n"],["\u003cp\u003eA mediation group can only have one active A/B experiment running at any given time.\u003c/p\u003e\n"],["\u003cp\u003eExperiments are managed using curl commands to create, monitor, and conclude the test, ultimately choosing the preferred variant for your mediation group.\u003c/p\u003e\n"]]],["The AdMob API facilitates mediation A/B experiments to optimize ad performance by comparing two mediation group configurations. Experiments can involve adding/removing ad sources, adjusting waterfall order/eCPM, enabling/disabling optimization, or changing call frequency. To set up an experiment, you must create a variation (variant B) of an existing mediation group (variant A), and define the percentage of users that will see variant B. To use the API, it is required to obtain an authorization, then you can create, check the status and stop the experiments. Only one experiment can be active in each mediation group at a time.\n"],null,["# Mediation A/B experiment\n\nThe AdMob API can create mediation A/B experiments to maximize your ads\nperformance by testing various configurations. An A/B test lets you evaluate\ntwo variations of a mediation group to compare the results side by side and\nselect a preferred configuration.\n\nHere are examples of experiments you can set up:\n\n- Adding or removing ad sources to see their impact on your mediation group\n- Using a different waterfall order by changing the manual eCPM value of ad sources\n- Enabling or disabling optimization on waterfall ad sources\n- Changing the number of times an ad source is called\n\nExamples\n--------\n\nStart with an existing mediation group and create a variation of it to see\nwhich variant, A or B, performs better. The test splits your app's users\nbetween your existing mediation group setup and the variation, based on a\npercentage (1%, 10%, or 50%) you provide.\n**Key Point:** A mediation group can only run one mediation A/B experiment at a time. \n\n### curl (command line)\n\n### Requests using curl\n\n1. **Load the [client secrets file](https://console.cloud.google.com/apis/credentials) and generate authorization\n credentials.**\n\n The first time you perform this step, you are asked to accept an\n authorization prompt in your browser. Before accepting, make sure you're\n signed in with a Google Account that has access to the AdMob API. Your\n app will be authorized to access data on behalf of whichever account is\n currently logged in.\n\n For authentication and authorization, we recommend using\n [oauth2l](//github.com/google/oauth2l), a simple command-line tool for\n working with Google OAuth 2.0. Install oauth2l and run the command below,\n replacing \u003cvar translate=\"no\"\u003epath_to_credentials_json\u003c/var\u003e with a path to a\n `credentials.json` file that you download when registering your cloud\n app. For the first run, the command walks you through the OAuth 2.0\n authorization flow. Subsequent runs refresh the token automatically. \n\n ```\n oauth2l header --json path_to_credentials_json --scope admob.monetization,admob.readonly\n ```\n2. **Create a mediation A/B experiment.**\n\n Replace `pub-XXXXXXXXXXXXXXXX` with your [publisher\n ID](//support.google.com/admob/answer/2784578) and `ZZZZZZZZZZ` with your\n mediation group ID. The mediation group ID can be found in the AdMob UI or\n by using the\n [`accounts.mediationGroups:list`](/admob/api/reference/rest/v1beta/accounts.mediationGroups/list)\n method.\n\n You need to specify the\n [`treatmentMediationLines`](/admob/api/reference/rest/v1beta/accounts.mediationGroups.mediationAbExperiments)\n and\n [`treatmentTrafficPercentage`](/admob/api/reference/rest/v1beta/accounts.mediationGroups.mediationAbExperiments),\n however, the\n [`controlMediationLines`](/admob/api/reference/rest/v1beta/accounts.mediationGroups.mediationAbExperiments)\n are inherited from the parent mediation group and do not need to be\n specified.\n | **Key Point:** Possible values for `treatmentTrafficPercentage` are 1, 10, or 50, representing 1%, 10%, and 50%, respectively.\n\n The following request creates a mediation A/B experiment where the\n treatment variant, also known as variant B, contains a single mediation\n line for the AdMob network using\n [`LIVE`](/admob/api/reference/rest/v1beta/MediationGroupLine#cpmmode) mode. \n\n ```\n curl --http1.0 \\\n -X POST https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups/ZZZZZZZZZZ/mediationAbExperiments \\\n -H \"Content-Type:application/json\" \\\n -H \"$(oauth2l header --json path_to_credentials_json --scope admob.monetization)\" \\\n --data @- \u003c\u003c EOF\n {\n \"displayName\":\"Mediation A/B Experiment Test Name\",\n \"treatmentTrafficPercentage\": \"50\",\n \"treatmentMediationLines\": [{\n \"mediationGroupLine\": {\n \"displayName\": \"Test mediation group line\",\n \"adSourceId\": \"5450213213286189855\",\n \"cpm_mode\": \"LIVE\"\n }\n }]\n }\n EOF\n ```\n\n See the sample response below where `SSSSSSSSSSSSSSSSSSSSSS` represents\n the created mediation A/B experiment ID and `YYYYYYYYYY` represents the\n last 10 digits of your [ad unit\n ID](//support.google.com/admob/answer/7356431), complying to the format:\n `ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY`. \n\n ```text\n {\n \"name\": \"accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups/ZZZZZZZZZZ/mediationAbExperiments/SSSSSSSSSSSSSSSSSSSSSS\",\n \"displayName\": \"Mediation A/B Experiment Test Name\",\n \"experimentId\": \"SSSSSSSSSSSSSSSSSSSSSS\",\n \"treatmentTrafficPercentage\": \"50\",\n \"treatmentMediationLines\": [\n {\n \"mediationGroupLine\": {\n \"id\": \"11111111111111111\",\n \"displayName\": \"Test mediation group line\",\n \"adSourceId\": \"5450213213286189855\",\n \"cpmMode\": \"LIVE\",\n \"cpmMicros\": \"10000\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/\n },\n \"state\": \"ENABLED\"\n }\n }\n ],\n \"controlMediationLines\": [\n {\n \"mediationGroupLine\": {\n \"id\": \"22222222222222222\",\n \"displayName\": \"AdMob Network (control)\",\n \"adSourceId\": \"5450213213286189855\",\n \"cpmMode\": \"LIVE\",\n \"cpmMicros\": \"10000\",\n \"adUnitMappings\": {\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/\n \"ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY\": \"accounts/pub-XXXXXXXXXXXXXXXX/adUnits/YYYYYYYYYY/adUnitMappings/\n },\n \"state\": \"ENABLED\"\n }\n }\n ],\n \"state\": \"RUNNING\"\n }\n ```\n3. **Verify the mediation A/B experiment is running.**\n\n Call\n [`accounts.mediationGroups:list`](/admob/api/reference/rest/v1beta/accounts.mediationGroups/list)\n to get the mediation A/B experiment status for that mediation group. See\n the [mediation groups\n guide](/admob/api/v1/mediation-groups) for more\n details.\n\n The\n [`mediationAbExperimentState`](/admob/api/reference/rest/v1beta/accounts.mediationGroups.mediationAbExperiments#experimentstate)\n is set to `RUNNING` for active mediation A/B experiments and `NOT_RUNNING`\n if there is no experiment running in the mediation group.\n\n Sample request: \n\n ```\n curl --http1.0 \\\n -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups \\\n -H \"$(oauth2l header --json path_to_credentials_json --scope admob.readonly)\"\n ```\n4. **Stop the mediation A/B experiment and select a variant.**\n\n Replace `pub-XXXXXXXXXXXXXXXX` with your [publisher\n ID](//support.google.com/admob/answer/2784578) and `ZZZZZZZZZZ` with your\n mediation group ID. The mediation group ID can be found in the AdMob UI or\n by using the\n [`accounts.mediationGroups:list`](/admob/api/reference/rest/v1beta/accounts.mediationGroups/list)\n method.\n\n To complete the experiment, specify the winning variant in the request:\n - `VARIANT_CHOICE_A`: Use the mediation lines from Variant A and complete the experiment. Variant A contains the original serving lines before the experiment creation.\n - `VARIANT_CHOICE_B`: Use the mediation lines form Variant B and complete the experiment. Variant B contains the newly added serving lines.\n\n Sample request: \n\n curl --http1.0 \\\n -X POST https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/mediationGroups/ZZZZZZZZZZ/mediationAbExperiments:stop \\\n -H \"Content-Type:application/json\" \\\n -H \"$(oauth2l header --json path_to_credentials_json --scope admob.monetization)\" \\\n --data @- \u003c\u003c EOF\n {\n \"variantChoice\": \"VARIANT_CHOICE_A\"\n }\n\n Sample response: \n\n ```text\n {\n \"experimentId\": \"SSSSSSSSSSSSSSSSSSSSSS\",\n \"state\": \"EXPIRED\",\n }\n ```"]]