Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback

Implement Advanced Audience Targeting for client-side SDKs - beta

How to implement Advanced Audience Targeting with client-side Optimizely Feature Experimentation SDKs.



Advanced Audience Targeting is currently in beta. Apply on the Optimizely beta signup page or contact your Customer Success Manager.

After creating a new audience with Advanced Audience Targeting and assigning it to a flag rule, you can integrate the audience segments in your client-side code.



If you are not familiar with targeted deliveries and experiments in Optimizely Feature Experimentation, it is recommended you follow the Quickstart guide for your specific SDK first before following this document.

Install and initialize the client-side SDK



You may need to upgrade your Optimizely Feature Experimentation SDK to the latest version in order to use Advanced Audience Targeting. Refer to the SDK compatabililty matrix to view the newest version available for your SDK.

The first step is to install and initialize the Optimizely Feature Experimentation SDK in your application. Refer to the following documentation for your SDK:


JavaScript (Browser)


More SDKs coming soon!

Audience targeting using OptimizelyUserContext

To fetch the audience segments your user qualifies for, you can use OptimizelyUserContext.

Known users

If you have a userID, you can create an OptimizelyUserContext object as usual with your Feature Experimentation userID and additional attributes. The OptimizelyUserContext object allows you to make flag decisions and track events for a user context.



When an OptimizelyUserContext is created, the SDK automatically sends an identify request to ODP.

Sending the identify event starts the customer profile merging process in ODP. Stitching VUIDs and userIDs lets any Feature Experimentation SDK (client or server-side) query ODP to get the complete customer profile.

To evaluate if your user would qualify in your audience, you can call fetchQualifiedSegments on the OptimizelyUserContext to fetch the ODP segments for the specific userID.

Refer to your specific SDK's documentation on creating a user context for details and code samples:

For information on the Advanced Audience Targeting methods, fetchQualifedSegments and isQualifiedFor refer to the following documentation:



If you do not provide a userID, client-side SDKs create an OptimizelyUserContext using an automatic generated VUID.

Anonymous users

If you do not have a userID, you can still see if the anonymous user qualifies for an audience segment using OptimizelyUserContext.

All client-side SDKs automatically generate a VUID or device ID if one cannot be found upon instantiation. Also, the SDK sends a register event automatically to ODP with the VUID when the SDK is instantiated. This is helpful when sending decision data before the user is logged in, such as in anonymous segmentation.

To evaluate if your anonymous user would qualify for your audience, you can callOptimizelyUserContext with no userID to fetch the user's ODP segments. Refer to your specific SDK's documentation on creating user context for details and code samples:



You can only call fetchQualifiedSegments after the datafile has been fetched.

After the datafile has been fetched, you can call fetchQualifiedSegments at any time to request fresh ODP segment qualifications

Make experiment decisions

You can use the standard Decide methods enriched with Advanced Audience Targeting to return flag decisions for a user using a userID or VUID. The flag decision includes flag enabled/disabled status and flag variation. When an ODP-type audience condition is required for the decision, the SDK can look up the ODP segments saved in the current user context. Refer to your specific SDK's documentation on calling the these methods:

Send events to Optimizely Data Platform

You can call sendOdpEvent() on the OptimizelyClient for sending arbitrary event data to ODP. For example, stitching an email address identifier to the Optimizely Feature Experimentation userID identifier. Refer to your SDK to learn more:

Customize configuration

You can customize the ODPManager or override the entire ODPManager with a custom one. But each Optimizely SDK implements its own way of supporting it.