HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In
Hey! These docs are for version 2.1.0-full-stack, which is no longer officially supported. Click here for the latest version, 1.0!

Retrieves a list of features that are enabled for the user. Invoking this method is equivalent to running Is Feature Enabled for each feature in the datafile sequentially.

This method takes into account the user attributes passed in, to determine if the user is part of the audience that qualifies for the experiment.

Version

SDK v2.1

Description

This method iterates through all feature flags and for each feature flag invokes Is Feature Enabled. If a feature is enabled, this method adds the feature’s key to the return list.

Parameter definitions

This section provides general information about the required and optional parameters.
For the specific parameter name in one of Optimizely's supported languages, see Parameter names.

Parameter

Type

Description

user ID
required

string

The ID of the user to check. For more information, see: Identify users.

attributes
optional

map

A map of custom key-value string pairs specifying attributes for the user. For more information, see: Define audiences and attributes.

Parameter names

This section shows the specific parameter names for each supported language.

userId
Attributes
userId
userAttributes
userId
attributes
userId
attributes
userId
attributes
userId
attributes
userId
attributes
user_id
attributes
user_id
attributes
user_id
attributes

Returns

A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user. The example shows the return as specified for each supported language.

@return A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.
/// <returns>List of the feature keys that are enabled for the user.</returns>
@return A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.
@return {Array} A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.
@return {Array} Array of feature keys (strings)
@return A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.
@return array List of feature flag keys
Returns:
    A list of the keys of the features that are enabled for the user.
@return [feature flag keys] A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.
@return NSArray<NSString> A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.

Examples

This section shows simple examples of how you can use the method.

List<String> enabledFeatures = optimizelyClient.getEnabledFeatures(GENERIC_USER_ID,
       Collections.singletonMap("house", "Gryffindor"));
var actualFeaturesList = OptimizelyMock.Object.GetEnabledFeatures(TestUserId, userAttributes);
ArrayList<String> featureFlags = (ArrayList<String>) spyOptimizely.getEnabledFeatures(genericUserId,
       new HashMap<String, String>());
var result = optlyInstance.getEnabledFeatures('user1', { test_attribute: 'test_value' });
var result = optlyInstance.getEnabledFeatures('user1', { test_attribute: 'test_value' });
NSArray<NSString *> *features = [self.optimizely getEnabledFeatures:kUserId attributes:self.attributes];
$enabledFeatures = $optimizelyClient->getEnabledFeatures('my_user', $userAttributes);
enabled_features = optimizely_instance.get_enabled_features(user_id, attributes)
enabled_features = optimizely_client.get_enabled_features('user_1', user_attributes)
static NSString *const kUserId = @"userId";

NSArray<NSString *> *features = [self.optimizely getEnabledFeatures:kUserId attributes:self.attributes];

Exceptions

None

See also

Get Feature Variable
Is Feature Enabled

Side effects

The table lists other other Optimizely functionality that may be triggered by using this method.

Functionality

Description

Impressions

Accessing this method triggers an impression if the user is included in a feature test. It doesn't trigger an impression if the user is in a rollout or if neither a test nor rollout is active.

Notes

This method has all the same arguments as Is Feature Enabled and also triggers impressions for any feature tests activated in the process.

Source files

The table lists the language/platform source files containing the implementations.

Language/Platform

Source files

Android

OptimizelyClient.java

C#

Optimizely.cs

Java

Optimizely.java

JavaScript

index.js

Node

index.js

Objective-C and Swift

Optimizely.h

PHP

Optimizely.php

Python

optimizely.py

Ruby

optimizely.rb