Optimizely will be sunsetting Full Stack Experimentation on July 29, 2024. See the recommended Feature Experimentation migration timeline and documentation.

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

Is Feature Enabled

This topic describes the Is Feature Enabled method, which determines whether a feature is enabled for a given user.

Determines whether a feature is enabled for a given user. The purpose of this method is to allow you to separate the process of developing and deploying features from the decision to turn on a feature. Build your feature and deploy it to your application behind this flag, then turn the feature on or off for specific users.


SDK v3.1.0


This method traverses the client's datafile and checks the feature flag for the feature key that you specify.

This method evaluates the feature rollout for a user. The method checks whether the rollout is enabled, whether the user qualifies for the audience targeting, and then randomly assigns either on or off based on the appropriate traffic allocation. If the feature rollout is on for a qualified user, the method returns True.


The table below lists the required and optional parameters in Swift.

StringThe key of the feature to check.

The feature key is defined from the Features dashboard.
StringThe ID of the user to check.
Dictionary<String, Any>A map of custom key-value string pairs specifying attributes for the user that are used for audience targeting.


YES if the feature is enabled for the user. Otherwise, false.


This section shows a simple example of how you can use the IsFeatureEnabled method.

// Evaluate a feature flag and a variable
let enabled = optimizely.isFeatureEnabled(featureKey: "price_filter", userId: userId)
NSDictionary *attributes = @{
  @"device": @"iPhone",
  @"lifetime": @24738388,
  @"is_logged_in": @true

BOOL enabled = [optimizely isFeatureEnabledWithFeatureKey:@"my_feature_key"

Source files

The language/platform source files containing the implementation for Swift is OptimizelyClient.swift.