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

Implement Advanced Audience Targeting for server-side SDKs - beta

How to implement Advanced Audience Targeting with server-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 server-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 server-side SDK



You may need to upgrade your 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. When initializing the SDK, you should enable the Optimizely Data Platform (ODP) audience segmentation. See the Customize configuration section for information on ODPManager customization options.

Refer to the following documentation for your SDK:

Advanced Audience Targeting usingOptimizelyUserContext



OptimizelyUserContext can only be created after the SDK instance is ready (the datafile has been fetched).

After you have installed and initialized the Optimizely client, you need to create an OptimizelyUserContext object with your Optimizely Feature Experimentation userID and additional attributes. The OptimizelyUserContext object lets you make flag decisions and track events for a user context that you have already created using the createUserContext method.



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

Call fetchQualifiedSegments() and then isQualifiedFor() on the OptimizelyUserContext object to first fetch the ODP segments for the specific userID or any time you need to check if the user context is qualified for a given ODP real-time segment. Refer to your chosen SDK's documentation on OptimizelyUserContext for details and code samples:

Make experiment decisions

You can use the standard Decide methods enriched with Advanced Audience Targeting to return flag decisions for a user. The flag decision includes flag-enabled or disabled status and flag variation. When an ODP-type audience condition is required for the decision, the SDK can look up the ODP segments in the current user context saved when fetchQualifiedSegments() is called. 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 to send arbitrary event data to ODP. Refer to your preferred SDK to learn more:

Customize configuration

You can customize the OdpManager or override the entire ODPManager with a custom one. But each Optimizely SDK has its own way of implementing it. Refer to your desired SDK to learn more: