Implement Advanced Audience Targeting for server-side SDKs
How to implement Optimizely Data Platform Advanced Audience Targeting with server-side Optimizely Feature Experimentation SDKs.
After creating a new audience with Advanced Audience Targeting and assigning it to a flag rule, you can start implementing 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 ODP audience segmentation. See the Customize configuration section for information on
ODPManager customization options.
Refer to the following documentation for your SDK:
- Optimizely Agent
Advanced Audience Targeting using
OptimizelyUserContextcan 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
OptimizelyUserContextis created, the SDK automatically sends an identify request to ODP.
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:
- Optimizely Agent
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:
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:
Updated 16 days ago