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 v1.0 and higher


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

  1. Analyzes the user's attributes.
  2. Hashes the userID.

The method evaluates if the feature is being experimented and the user falls in this experiment based on Target audiences and traffic allocation. The method returns true if this is the case otherwise evaluates if the user is in feature rollout. 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 Go.

stringThe key of the feature to check.

The feature key is defined from the Features dashboard. For more information, see Create feature flags.
entities.UserContextHolds information about the user, such as the userID and the user's attributes.


The value this method returns is determined by your feature flags. This example shows the specific value returned for Go:

True if feature is enabled. Otherwise, false or null.


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

attributes := map[string]interface{}{
        "DEVICE": "iPhone",
        "hey":    2,

user := entities.UserContext{
        ID:         "userId",
        Attributes: attributes,

isEnabled, err := optlyClient.IsFeatureEnabled("feature_key", user)

Side Effects

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

ImpressionsAccessing this method triggers an impression if the user is included in an active Feature test.
NotificationsInvokes the DECISION [notification] callback if this notification is subscribed to.

The example code below shows how to add and remove a decision listener.

import (


// Callback for decision notification
callback := func(notification notification.DecisionNotification) {

  // Access type on decisionObject to get type of decision
  // Access decisionInfo on decisionObject which
  // will have form as per type of decision.

optimizelyClient, err := optimizelyFactory.Client()

// Add callback for decision notification
id, err := optimizelyClient.DecisionService.OnDecision(callback)

// Remove callback for decision notification
err = optimizelyClient.DecisionService.RemoveOnDecision(id)



Source files

The language/platform source files containing the implementation for Go is Go.