Rollouts

The Rollouts Developer Hub

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

Get Started    

Create feature flags

Feature flags, also known as feature toggles or permission toggles, are a software development technique that lets you turn certain functionality on and off without deploying new code.

Feature flags allow for better control over the full lifecycle of features. You can toggle a feature off to release code quickly without exposing it to users. You can also roll it out to a fraction of your user base to minimize the impact of the launch, allowing you to validate functionality and measure performance prior to rolling out broadly.

Optimizely supports advanced feature flagging through the core concept of a feature identified by a unique key like shopping_cart or price_filter.

In Optimizely, you can manage all your feature flags in one interface. Below, we cover how to create, edit, and archive a feature flag.

Create feature

To create a feature, navigate to Features > Create New Feature.

Click to enlarge.

Click to enlarge.

  1. In the Feature Key field, give the flag a unique name. Valid keys contain alphanumeric characters, hyphens, and underscores, are limited to 64 characters, and can't contain spaces. You’ll use the feature key to determine whether the feature is on or off in your code.
  2. Add an audience (optional), or a group of users, who you'd like to make this feature available.
  3. Implement the feature flag. Optimizely automatically populates example code for an API call with your feature key.

The example below shows how you can evaluate the feature flag with the Is Feature Enabled method. This lets you build conditional branches in your code, showing the feature if enabled is true and hiding it otherwise. You can also get a list of all the features that are enabled for a user using the Get Enabled Features method.

The goal of these methods is to separate the process of developing and releasing code from the decision to turn a feature on. Build your feature and deploy it to your application behind this flag, then turn the feature on or off for specific users by running tests and rollouts. The value this method returns is determined by your test(s) and rollout associated with the feature. For example, if the current user is assigned to a variation in a feature test for which the feature is on, the method returns true. Otherwise, it returns false.

import com.optimizely.ab.android.sdk.OptimizelyClient;

// Evaluate a feature flag
Boolean enabled = optimizelyClient.isFeatureEnabled("price_filter", userId);

using OptimizelySDK;

var optimizelyClient = new Optimizely(datafile);
string userId = "";

// Evaluate a feature flag
bool enabled = optimizelyClient.IsFeatureEnabled("price_filter", userId);

import com.optimizely.ab.Optimizely;

// Evaluate a feature flag
Boolean enabled = optimizelyClient.isFeatureEnabled("price_filter", userId);

// Evaluate a feature flag
var enabled = optimizelyClientInstance.isFeatureEnabled('price_filter', userId);

// Evaluate a feature flag
var userId = `test${Date.now()}.${Math.random()}`;
const enabled = optimizelyClient.isFeatureEnabled("price_filter", userId);
console.log(`Price filter enabled: ${enabled}`);

// Evaluate a feature flag and a variable
BOOL enabled = [optimizely isFeatureEnabledWithFeatureKey:@"price_filter"
                                                		userId:userId];

NSNumber *min_price = [optimizely getFeatureVariableIntegerWithFeatureKey: @"price_filter"
																										variableKey:@"min_price"
																										userId:userId
																										error:nil];

// Evaluate a feature flag
$enabled = $optimizelyClient->isFeatureEnabled('price_filter', $userId);

from optimizely import optimizely

optimizely_client = optimizely.Optimizely(datafile)

# Evaluate a feature flag
enabled = optimizely_client.is_feature_enabled('price_filter', user_id)

# Evaluate a feature flag
enabled = optimizely_client.is_feature_enabled('price_filter', user_id)

// Evaluate a feature flag and a variable
do {
  let enabled = optimizely.isFeatureEnabled(featureKey: "price_filter",
                                                          userId: userId)
	let min_price = try optimizely.getFeatureVariableInteger(featureKey: "price_filter",                                                                           															variableKey: "min_price",
																			userId: userId)
} catch {
   // error
}

  1. Click Create Feature to save your new feature.

You'll return to this feature whenever you want to update the feature flag. You can add and remove audiences, toggle the feature on in different environments, roll it out or back, and refer to the example code.

Target to an audience

Target feature rollouts using to audiences, or groups of users based on attributes you define. You can target any feature to more than one audience.

  1. To target one or more audiences for a rollout, navigate to Features and click the feature.
  1. In the Audiences section, click the names of the audiences you want to add. Multiple audiences are combined with the Boolean operator OR.
  2. Click Save.

Roll out and roll back

After you've created your feature flag in Optimizely and implemented it in your code, you can control it directly from the Optimizely interface without redeploying code.

For example, switch the feature on in development and off in production. Or, roll it out incrementally in production by moving the slider up by 10% per day. Show the feature only to a certain audience of users. Move it to 100% for a big reveal, or 0% if issues arise.

Navigate to Features and select your feature.

To roll out a feature:

  1. Click Features in the left navigation and select a feature.
  2. Under Rollout, select an environment from the dropdown.
  3. Toggle Feature to On, and adjust the traffic allocation.
  4. Click Save.

Updated 7 months ago


Create feature flags


Suggested Edits are limited on API Reference Pages

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