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    

Target audiences

Audiences give you control over which users are included in a rollout and have access to your feature.

You'll describe which users to include based on custom attributes like their location, device type, or subscription plan. After you create an audience, you can add it to your feature.

Resource
Description

3-minute video explaining high-level how Audience targeting works in Optimizely

A single audience is defined based on user attributes. These attributes are properties of a user that you pass in when calling APIs like Is Feature Enabled. When you pass attribute values, Optimizely uses them to determine whether the user qualifies for rollout.

Create an audience

After you've implemented a few attributes, you can start building audiences. You can reuse audiences that you've created across multiple flags and rules.

Optimizely supports several match types that you can use in audience conditions:

  • has any value
  • String equals
  • String contains substring
  • Boolean is false
  • Boolean is true
  • Number equals
  • Number is less than
  • Number equals
  • Number is greater than

The Edit Audience window lets you define audience conditions by either dragging and dropping attributes from the right side pane or defining complex JSON objects using the Code Mode window.

To create audiences from attributes:

  1. Navigate to Audiences > Saved.
  2. Click Create New Audience.
  3. Drag and drop the desired attributes into the Audience Conditions field.
    For example, to create an audience of visitors who are located in the US, based on specific location values, add the "LOCATION" attribute.
  4. Define the attributes. See Define attributes.
    Add other attributes to help create your audience. They can be can be added as "and" or "or" conditions. When you choose any match type option other than String equals for exact matching, a message displays that the option requires using an SDK version of 3.0, at minimum.
  5. Click Save Audience.

After creating an audience, you can set the target audience or audiences for a feature test, or feature rollout.

Create audience combinations

Using the Optimizely opp, you can easily use "and", "or" operators (i.e., 'any' or 'all') to create an audience combination composed of other audiences:

Add multiple audiences

You can assign multiple audiences, including audience combinations, to feature tests and feature rollouts.

Multiple audiences, including an audience combination

Multiple audiences, including an audience combination

Tips and tricks

Here are some tips and tricks for using audiences:

  • To QA an experiment, base an audience on a test cookie. Use the cookie to manually force a variation. See Use a QA audience.
  • To schedule turning on a feature flag, base an audience on an epoch time attribute. First, compute the time in your application, then pass the time in as an attribute. In this scenario, your audience attribute condition would look something like time number is greater than 12312412 and time number is less than 12355555.

Gotchas

Excluding audiences

You can easily use audiences to include or "whitelist" users, but not to exclude them.
For example, you can't exclude all Brazilian users by simply dialing back to 0% traffic for that audience. That's because if you turn off audience evaluation for Brazilian users, they end up in the "Everyone" audience.
To actually exclude or blacklist audiences, you need to define audience combinations using JSON. For more information, see Create advanced audience combinations.

Brazilians end up in "Everyone" unless you define an advanced audience combination

Brazilians end up in "Everyone" unless you define an advanced audience combination

Rollouts vs. experiment audience matching

In rollouts, as soon as an audience member for a rule is bucketed out of receiving a feature, they bypass all other audience conditions and go straight to Everyone Else.

For example, if a user, Ahmad Amin, qualified for an 'opt-in beta' audience for audience 1, but then did not bucket into an enabled feature flag, Ahmad would not be considered for any other audience condition he might qualify for. As the following diagram shows, Ahmad would bypass all other audiences and go straight to Everyone Else:

Rollouts audience matching

Rollouts audience matching

In contrast, if you define multiple overlapping audiences for an experiment, each user who qualifies for an audience but receives a disabled feature flag can still match to audiences other than Everyone.

Advanced audience combinations

If you want to use more sophisticated nested logical operators (and, or, not), you can do so in JSON in Code Mode. Each audience is a rule like "User likes salads", and an audience combination is a Boolean combination of these rules, like "User likes pizza NOT (User likes sandwiches AND User likes soup)."

For more information, see Configure a custom audience combination

Updated about a month ago


Target audiences


Suggested Edits are limited on API Reference Pages

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