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 GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Notification listeners

This topic describes what notification listeners are and lists which methods or lifecycle events trigger notification listeners in Optimizely.

Notification listeners allow you to programmatically observe and act on various events that occur within the SDK. Notification listeners:

  • Give you flexibility in implementing custom integrations with analytics provider.
  • Enable integrations by passing data to external services.

Here are a few examples for using notification listeners:

  • Send data to an analytics service and report feature flag decision data, for example, report that user_123 was assigned to variation A.
  • Use SDK events to send alerts to data monitoring tools like New Relic and Datadog to better visualize how A/B tests affect service-level metrics.
  • Pass all events to an external data tier, like a data warehouse, for additional processing and to leverage business intelligence tools.
  • Re-initialize your SDK to retrieve updated feature flag configuration data for your business-critical features.

The listeners work by triggering a callback function that you define and provide at runtime.

The following methods or lifecycle events trigger notification listeners if you have implemented the listener:

MethodNotification listener invoked
ActivateIn SDKs released Feb 2019 and earlier: Invokes the ACTIVATE notification listener if the user is included in an active A/B test.

In SDKs released after Feb 2019: Invokes the DECISION notification listener if this listener is enabled.
Get Feature VariableIn SDKs v3.1 and later: Invokes the DECISION notification listener if this listener is enabled.
TrackInvokes the TRACK notification listener if this listener is enabled.
Important! This method won't call the TRACK notification listener when the specified event key is invalid
Get all feature variablesInvokes the DECISION notification listener if this listener is enabled.
Get variationInvokes the DECISION notification listener if this listener is enabled.
Is Feature EnabledInvokes the DECISION notification listener if this listener is enabled.

Also invokes the ACTIVATE notification listener if the decision is the result of the visitor being included in an active feature test, and if this listener is enabled.
Lifecycle eventNotification listener invoked
event batch flushedInvokes the LOGEVENT notification listener if this listener is enabled
new datafile retrievedInvokes the OPTIMIZELYCONFIGUPDATE notification listener if this listener is enabled.