Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Run a beta

How to run a beta using a targeted delivery flag rule in Optimizely Feature Experimentation.

Run a beta by showing a flag to a specific subset of users instead of rolling your flag out to a random percentage of your user base.



This topic assumes you have already created a feature flag in the Optimizely Feature Experimentation Application

1. Decide on an attribute

An attribute is a property in your data that can be used to target a flag to a given customer or user. Decide which attribute to use for your beta based on the data you have available in your application. For example:

  • If you have a business application that has multiple accounts and want to run a beta account by account, consider making the unique account identifier in your application an attribute in Optimizely Feature Experimentation (ex: customerId, accountId, projectId, etc.).

  • If you have a consumer application with multiple users, and you would like to run your beta user by user, consider making the unique user identifier in your application an attribute in Optimizely Feature Experimentation (for example, userId).

2. Implement the attribute

The next step is to create an attribute in Optimizely Feature Experimentation for the attribute selected above. For example, if you were running a beta by enabling flags for a particular customerId, create an attribute in Optimizely Feature Experimentation with the keycustomertId.

In your code, pass the value from the data available in your application as an attribute to create a user. The below example shows how you would do this if you were running a beta based on customerId:

// create a hardcoded beta user. Edit this example to fetch accountID & userID (for example, from customer dB)
let user = optimizely.createUserContext(userId: "123", attributes: ["customerId": 789])
let decision = user.decide(key: "new_feature")

// execute code based on flag enabled state
let enabled = decision.enabled

3. Create a beta audience

Once you have implemented the attribute, you will use it for the beta, Target audiences for the beta users of your flag.

  • Name – Include the flag key in the audience name, so you can easily determine which flag this audience is for. For example, if your flag key was chat_window, we recommend naming the audience "[chat_window] Beta Users"

  • Audience conditions – Drag and drop the attribute that determines who gets access to the beta. For the value of the condition, use an internal or test identifier to include yourself in the beta first to make sure everything is correctly set up.



Be sure to match the value with the attribute's appropriate type.

  • If your attribute is an integer, select Number equals.
  • If your attribute is a string, select String equals.
create new audience based on attributes

Create a targeted delivery for the audience you created previously and save, ensuring that the percentage delivery is configured to 100%:

create targeted delivery rule

5. Add further audiences

Your beta is running now that you have added the audience to your flag. After your first beta audience, you can retain them at 100% and strategically roll out to a sequence of audiences using multiple targeted deliveries. For example, you could define audiences to roll out to, such as:

  • Other beta audiences.
  • Lowest value customers.
  • Difficult migration customers.
  • All customers signing up in the last 20 days.
  • Highest value customers.
add more audiences


When all your audiences are at 100% traffic, you launched! Congratulations!

Next steps

To optimize your feature flag during or after delivery, test variations of your flag. For more information, see Run A/B tests.