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    

Set up notification listener

When rolling out features, you'll want to know when users are accessing a feature flag and what experience they're receiving in production.

Although Optimizely Rollouts doesn't offer analytics on feature flags out of the box, you can still track analytics on feature flag usage by adding a notification listener to send events to the analytics provider of your choice.

Notification listeners trigger a callback function that you define when certain actions are triggered in the SDK.

The most common use case is to send a stream of all feature flag decisions to an analytics provider or to an internal data warehouse to join it with other data that you have about your users.

To track feature usage:

  1. Sign up for an analytics provider of your choice (for example, Segment)
  2. Set up a notification listener of type 'DECISION'
  3. Follow your analytics provider's documentation and send events from within the decision listener callback

Steps 1 and 3 aren't covered in this documentation. However, setting up a 'DECISION' notification listener is covered below.

Set up a DECISION notification listener

The DECISION notification listener enables you to be notified whenever the SDK determines what decision value to return for a feature. The callback is triggered with the decision type, associated decision information, user ID, and attributes.

DECISION listeners are triggered when you call Is Feature Enabled or Get Enabled Features.

To set up a DECISION listener:

  1. Define a callback to be called when the DECISION event is triggered
  2. Add the callback to the notification center on the Optimizely instance

The example code below shows how to add a listener, remove a listener, remove all listeners of a specific type (such as all decision listeners), and remove all listeners.

// Add a notification listener
let notificationId = optimizely.notificationCenter.addDecisionNotificationListener(decisionListener: { (type, userId, attributes, decisionInfo) in    
    // Send data to analytics provider here

// Remove a specific notification listener
optimizely.notificationCenter.removeNotificationListener(notificationId: notificationId!)

// Remove notification listeners of a certain type
optimizely.notificationCenter.clearNotificationListeners(type: .decision)

// Remove all notification listeners

// Add a notification listener
NSNumber *notificationId = [self.optimizely.notificationCenter addDecisionNotificationListenerWithDecisionListener:^(NSString *type, NSString *userId, NSDictionary<NSString *,id> *attributes, NSDictionary<NSString *,id> *decisionInfo) {
    // Send data to analytics provider here

// Remove a specific listener
[optimizely.notificationCenter removeNotificationListenerWithNotificationId:notificationId];

// Remove all of one type of listener
[optimizely.notificationCenter clearNotificationListenersWithType:NotificationTypeDecision];

// Remove all notification listeners
[optimizely.notificationCenter clearAllNotificationListeners];

The tables below show the information provided to the listener when it is triggered.




  • feature: Returned when you use the Is Feature Enabled to determine if user has access to one specific feature, or Get Enabled Features method to determine if user has access to multiple features.
    • Is Feature Enabled returns a boolean value.
    • Get Enabled Features returns an array of strings consisting of all features in the project enabled for the user.

decision info


Key-value map that consists of data corresponding to the decision and based on the type.
See the table below for valid fields and values for each type.

user ID


The user ID.



A map of custom key-value string pairs specifying attributes for the user that are used for audience targeting. Non-string values are only supported in the 3.0 SDK and above.

Decision Info Values


  • feature_key: String id of the feature.
  • feature_enabled: True or false based on whether the feature is enabled for the user.
  • source: String denoting how user gained access to the feature. Value is:
    • rollout if the feature became enabled or disabled for the user because of the rollout configuration associated with the feature.

Updated 9 months ago

Set up notification listener

Suggested Edits are limited on API Reference Pages

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