The Full Stack Developer Guide Developer Hub

Welcome to the Full Stack Developer Guide developer hub. You'll find comprehensive guides and documentation to help you start working with the Full Stack Developer Guide as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Set audiences for experiments and rollouts

After defining an audience, you can set the target audience or audiences for an A/B test, feature test, or feature rollout.

Full Stack v3.0 supports three types of audience combination:

  • Match any audience
  • Match all audiences
  • Custom combination (via Code Mode)

Audience combination differences between v3.0 SDKs and prior versions

Only the v3.0 SDKs can activate experiments and rollouts that use audience combinations other than "Match any audience." The v1.x and v2.x SDKs only allow you to use the "Match any audience" audience combination for experiments and rollouts.

Warning

If an experiment or rollout using the "Match all audiences" or "Custom" audience type is evaluated with a 1.x or 2.x SDK, targeting won't pass and conversions and impressions will be lost.

Configure a match with any or all audiences

To configure a match with any or all audiences:

  1. Navigate to the experiment you want to configure and click Audiences.
  2. Add the audiences for the experiment.
  3. Select the appropriate match option:
    • Match any audience: During audience evaluation for a visitor, experiment activation happens if that visitor matches at least one of the added audiences.
    • Match all audiences: During audience evaluation for a visitor, experiment activation happens only if the visitor matches all of the added audiences.
  4. (Optional) Click Code Mode to view the resulting condition code for the defined match combination. See Configure a custom audience combination for information about creating and passing a custom audience combination with JSON.
  5. Click Save.

Configure a custom audience combination

For experiments and rollouts, you can configure custom audience combinations to determine which combination of audiences is required to pass evaluation.

Define audience combinations using logical rules called conditions. Each condition is a rule like "User likes salads", and an audience combination is a Boolean combination of these rules, like "User likes salads OR User likes sandwiches."

Step 1: Get the audience identifiers

Each individual condition is a JSON object with an audience_id. You can add these identifiers directly in Code Mode or find them by selecting Match any audience or Match all audiences, selecting the audience, and switching to Code Mode.

Step 2: Update Code Mode JSON

Select Code Mode to access the code editor and define your JSON audience combination.

The Evaluated Audiences field provides a summary of the defined conditions, which allows you to verify the audience combination's definition and accuracy.

Step 3: Define the conditions

Conditions are joined together in lists:

  • The first element in each list is an operator, "and", "or", or "not", and the rest of the conditions are combined using that operator.
  • You can replace any individual condition with another list, which allows for a nested structure of "and" and "or" conditions.
  • A "not" list should only have one condition or list, which will be negated. A "not" with a list of other conditions like ["not", ["and", {...}, {...}]] can negate the entire result of the child condition list.

The example below shows how you could define audience combination conditions. You can also create an experiment or rollout with an audience combination in Optimizely and look at the Code Mode view.

// "User who loves salads"
// or "User who loves sandwiches"
[
  "or",
  {
    "audience_id": 1038980040
  },
  {
    "audience_id": 1033280055
  }
]

// "User who loves salads"
// or "User who loves sandwiches"
// or doesn't "Like both salads & sadwiches"
[
  "or",
  {
    "audience_id": 1038980040
  },
  {
    "audience_id": 1033280055
  },
  [
    "not",
    {
      "audience_id": 1120870079
    }
  ]
]

// Is not "User who loves salads"
// AND is not "User who loves sandwiches"
[
  "not",
  [
    "and",
    {
      "audience_id": 1038980040
    },
    {
      "audience_id": 1033280055
    }
  ]
]

Optional: Use the REST API to save the audience combination

As an optional final step, you can HTTP PUT the audience combination as a serialized string (for example, by using JSON.stringify(data) in JavaScript) via the audience_conditions key and /experiments or /features REST API endpoint.

We'll return it in the same format, so to traverse it you'll need to parse it as an object (for example, by using JSON.parse(string) in JavaScript).

For more information about the REST API endpoints, see:

Note

You can use the same audience_conditions format for the /experiments and /features REST API endpoints.

For the REST API, the only difference is that you must use a value of "everyone" for audience_conditions to target the experiment or rollout accordingly (i.e., everyone should be allowed).


Set audiences for experiments and rollouts


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.