POST /experiments
Create an Experiment in a Project
Servers
- https://api.optimizely.com/v2
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/json" |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
action |
String | No |
Action to change the state of the experiment. Valid values:
|
Request body fields
| Name | Type | Required | Description |
|---|---|---|---|
metrics[] |
Array | No |
An ordered list of metrics to track for the Experiment. Required for Web, Full Stack, and Mobile Experimentation. Not applicable for Web Personalization Experiences. |
metrics[].aggregator |
String | No |
The aggregation function for the numerator of the metric. 'unique' measures the number of unique visitors/sessions that include the specified Event. 'count' measures the total number of occurrences of Event for the scope (visitor/session). 'sum' is the sum of the 'field' value Valid values:
|
metrics[].field |
String | No |
The field to aggregate for the numerator of the metric. Required when 'aggregator' = 'sum', otherwise omitted Valid values:
|
metrics[].winning_direction |
String | No |
The winning direction of this metric Valid values:
|
metrics[].event_id |
Integer | No |
The ID for the Event to select data from. Omitted for global metrics that are not relative to a specific Event, i.e. "overall revenue" |
metrics[].scope |
String | No |
Specifies how Events should be grouped together. Can also be thought of as the denonimator of the metric. 'session' divides by the number of sessions. "Influenced sessions", or sessions that do not contain a decision Event but carry a decision from a previous session are not included in counts for numerator or denominator. 'visitor' divides by the number of visitors. 'event' divides by the total occurrences (impressions) of the specified Event Valid values:
|
page_ids[] |
Array | No |
A list of Page IDs used in the Experiment. |
description |
String | No |
The description or hypothesis for an Experiment |
feature_key |
String | No |
The key for the Feature attached to the Experiment. Applies to Feature Tests only. Valid keys contain alphanumeric characters, hyphens, and underscores, and are limited to 64 characters. |
multivariate_traffic_policy |
String | No |
For Experiments of type Valid values:
|
last_modified |
String | No |
The last time the Experiment was modified |
url_targeting |
Object | No | |
url_targeting.activation_type |
String | No |
How this page is activated. See the full documentation on the Page object. Valid values:
|
url_targeting.key |
String | No |
Unique string identifier for this Page within the Project |
url_targeting.activation_code |
String | No |
Stringified Javascript function that determines when the Page is activated. Only required when activation_type is 'polling' or 'callback'. |
url_targeting.conditions |
String | No |
Conditions to activate the experiment; our knowledge base article on Activation Types is the best guide for how to set up this data. |
url_targeting.page_id |
Integer | No |
The unique identifier of the Page that represents the experiment or campaign's URL Targeting. |
url_targeting.edit_url |
String | Yes |
URL to load in the editor for this page |
allocation_policy |
String | No |
Traffic allocation policy across variations in this experiment |
id |
Integer | No |
The unique identifier for the Experiment |
whitelist[] |
Array | No |
A list containing the user IDs and variations of users who have been whitelisted |
whitelist[].variation_id |
Integer | Yes |
The unique identifier for the variation |
whitelist[].user_id |
String | Yes |
The ID of the user being whitelisted |
created |
String | No |
The time when the Experiment was initially created |
holdback |
Integer | No |
Percent of traffic to exclude from the experiment, measured in basis points. 100 basis points = 1% traffic. For example, a value of 9900 would mean that 1% of visitors will be eligible for the experiment. This is only applicable for Web. |
key |
String | No |
Unique string identifier for this Experiment within the Project. Only applicable for Full Stack and Mobile projects. |
type |
String | No |
Indicates whether this is an Valid values:
Default value: "a/b" |
project_id |
Integer | Yes |
The Project the Experiment is in |
audience_conditions |
String | No |
The audiences that should see this experiment. To target everyone, use the string "everyone" or omit this field. Multiple audiences can be combined with "and" or "or" using the same structure as audience conditions Default value: "everyone" |
variations[] |
Array | No |
A list of variations that each define an experience to show in the context of the Experiment for the purpose of comparison against each other |
variations[].actions[] |
Array | No |
A collection of changes to run for each page in an experiment. Only applicable to Optimizely X Web. |
variations[].actions[].changes[] |
Array | No |
The list of changes to apply to the Page. If 'dependencies' is supplied in a Change within 'changes', each ID in 'dependencies' must also be in 'changes'. |
variations[].actions[].changes[].preserve_parameters |
Boolean | No |
Whether or not to preserve parameters from original request when redirecting to new destination URL. Required for changes of type 'redirect'. For redirects using |
variations[].actions[].changes[].attributes |
Object | No | |
variations[].actions[].changes[].attributes.href |
String | No |
Value of href attribute to add to element(s) matched by a selector |
variations[].actions[].changes[].attributes.html |
String | No |
Value of HTML attribute to add to element(s) matched by a selector |
variations[].actions[].changes[].attributes.remove |
Boolean | No |
Whether or not to remove the element(s) matched by a selector |
variations[].actions[].changes[].attributes.text |
String | No |
Value of text attribute to add to the element(s) matched by a selector |
variations[].actions[].changes[].attributes.hide |
Boolean | No |
Whether or not to hide the element(s) matched by a selector |
variations[].actions[].changes[].attributes.class |
String | No |
Name of the class to set the element(s) matched by a selector to |
variations[].actions[].changes[].attributes.src |
String | No |
Value of src attribute to add to element(s) matched by a selector |
variations[].actions[].changes[].attributes.style |
String | No |
Value of style attribute to add to element(s) matched by a selector |
variations[].actions[].changes[].destination_function |
String | No |
A function string to redirect to. Required for changes of type 'redirect'. |
variations[].actions[].changes[].destination |
String | No |
URL to redirect to. Required for changes of type 'redirect'. |
variations[].actions[].changes[].rearrange |
Object | No |
A directive to place the DOM element(s) matched by 'selector' to the position of the element matched by 'insertSelector', with the relation specified by 'operator'. The supplied example moves element matched by 'selector' above the element of class .greyBox |
variations[].actions[].changes[].config |
Object | No |
Configuration properties for the extension |
variations[].actions[].changes[].value |
String | No |
The value for the change can be custom Javascript or CSS as a string. Required for changes of type 'custom_css' and 'custom_code' |
variations[].actions[].changes[].extension_id |
String | No |
ID of the extension to insert. Required for changes of type 'extension' |
variations[].actions[].changes[].id |
String | No |
The ID of the change |
variations[].actions[].changes[].selector |
String | No |
CSS selector to determine where changes are applied. Required for changes of type 'attribute', 'insert_html', and 'insert_image' |
variations[].actions[].changes[].name |
String | No |
Name of the change |
variations[].actions[].changes[].operator |
String | No |
Where to instert HTML or image for types 'insert_html' and 'insert_image' with respect to the element(s) matched by 'selector' |
variations[].actions[].changes[].dependencies[] |
Array | No |
A list of dependent change IDs that must happen before this change |
variations[].actions[].changes[].src |
String | No |
The path to the change payload on the CDN. Only present if 'async' is True. |
variations[].actions[].changes[].css |
Object | No | |
variations[].actions[].changes[].css.font-size |
String | No | |
variations[].actions[].changes[].css.height |
String | No | |
variations[].actions[].changes[].css.border-width |
String | No | |
variations[].actions[].changes[].css.width |
String | No | |
variations[].actions[].changes[].css.background-image |
String | No | |
variations[].actions[].changes[].css.border-style |
String | No | |
variations[].actions[].changes[].css.font-weight |
String | No | |
variations[].actions[].changes[].css.position |
String | No | |
variations[].actions[].changes[].css.background-color |
String | No | |
variations[].actions[].changes[].css.border-color |
String | No | |
variations[].actions[].changes[].css.color |
String | No | |
variations[].actions[].changes[].type |
String | Yes |
The type of this change.
Valid values:
|
variations[].actions[].changes[].allow_additional_redirect |
Boolean | No |
Whether or not to allow additional redirects after redirecting to destination. Required for changes of type 'redirect' |
variations[].actions[].changes[].async |
Boolean | No |
Indicates whether or not to execute the change asyncronously. If true, src will be returned in the response. Otherwise, it will be not included. |
variations[].actions[].share_link |
String | No |
The share link for the provided Variation and Page combination |
variations[].actions[].page_id |
Integer | Yes |
The ID of the Page to apply changes to |
variations[].name |
String | No |
The name of the variation. Required for Web Experiments and Personalization experiences. Not required for Full Stack Experiments. |
variations[].archived |
Boolean | No |
Whether the variation is archived |
variations[].description |
String | No |
A description of the variation. |
variations[].key |
String | No |
Unique string identifier for this variation within the Experiment. Only applicable for Full Stack and Mobile projects. |
variations[].feature_enabled |
Boolean | No |
For Feature Tests, indicates if the feature should be enabled for the variation |
variations[].variable_values |
Object | No |
For Feature Tests, the variable values for the variation represented as a map of Variable keys to their values. |
variations[].status |
String | No |
Current status of the variation Valid values:
|
variations[].weight |
Integer | Yes |
The percentage of your visitors that should see this variation, measured in basis points. 100 basis points = 1% traffic. Variation weights must add up to 10000. |
variations[].variation_id |
Integer | No |
The unique identifier for the variation |
latest |
String | No |
The last time the Experiment was paused (not present if the Experiment is still running). For campaign experiences, this field represents the last time the Campaign was paused. |
results_token |
String | No |
temporary token based on experiment id, used to access data platform services from other parts of the product |
schedule |
Object | No | |
schedule.time_zone |
String | No |
The time zone to use for Experiment start and stop times with respect to an IANA time zone (ex. "America/New_York"). The time zones expressed by GMT (e.g. "GMT-08:00") are no longer supported. Default value: "UTC" |
schedule.start_time |
String | No |
The start time for the Experiment, in date-time or date format (as defined by ISO 8601), and rounded to the nearest minute. If only date is supplied without time, the start time defaults to 00:00 on the specified start date. |
schedule.stop_time |
String | No |
The stop time for the Experiment, in date-time or full-date format (as defined by ISO 8601), and rounded to the nearest minute. If only date is supplied without time, the stop time defaults to 00:00 on the specified stop date. |
status |
String | No |
Current state of the Experiment. Valid values:
|
campaign_id |
Integer | No |
For Personalization experiences, this ID corresponds to the parent Campaign. For standalone experiments this campaign_id does not correspond to a campaign object. |
environments |
Object | No |
String identifier for the Experiment's status in each Environment based on the environment key. |
environments.name |
Object | No | |
environments.name.status |
String | Yes |
The Experiment's status in different Environments based on the environment key. Valid values:
|
changes[] |
Array | No |
Custom CSS or JavaScript that will run before all variations in the Experiment (for Experiments in Web Projects only) |
changes[].id |
String | No |
The ID of the change |
changes[].selector |
String | No |
CSS selector to determine where changes are applied. Required for changes of type 'custom_css'. |
changes[].name |
String | No |
Name of the change |
changes[].dependencies[] |
Array | No |
A list of dependent change IDs that must happen before this change |
changes[].src |
String | No |
The path to the change payload on the CDN. Only present if 'async' is True. |
changes[].type |
String | Yes |
The type of this change. Valid values:
|
changes[].value |
String | Yes |
The value for the change can be JavaScript or CSS as a string. |
changes[].async |
Boolean | No |
Indicates whether or not to execute the change asyncronously. If true, src will be returned in the response. Otherwise, it will be not included. |
name |
String | No |
Name of the Experiment. Required for Web Experimentation. Optional for Web Personalization experiences and Full Stack experiments. Not applicable for Mobile Experiments. |
earliest |
String | No |
The first time the Experiment was activated |
traffic_allocation |
Integer | No |
Percent of traffic allocated for the experiment, measured in basis points. 100 basis points = 1% traffic. For example, a value of 5500 would mean that 55% of visitors will be eligible for the experiment. This is only applicable for Full Stack. |
feature_name |
String | No |
The feature flag name to display in the Optimizely app. Whitespaces and other non-alphanumeric characters allowed. Defaults to feature key if left empty. |
is_classic |
Boolean | No |
Whether or not the Experiment is a classic Experiment. If true, the Experiment is read-only Default value: false |
feature_id |
Integer | No |
The ID of a Feature to attach to the Experiment. This turns an Experiment into a Feature Test. |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.