Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Implement Real-Time Segments for Feature Experimentation for server-side SDKs

How to implementReal-Time Segments for Feature Experimentation with server-side SDKs.

After creating an audience with Real-Time Segments for Feature Experimentation 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

🚧

Important

You may need to upgrade your SDK to the latest version to use Real-Time Segments for Feature Experimentation. Refer to the SDK compatibility 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:

C# –

Java –

JavaScript (Node)

Go –

Python –

Ruby –

Optimizely Agent

Real-Time Segments for Feature Experimentation usingOptimizelyUserContext

📘

Note

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.

📘

Note

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 Real-Time Segments for Feature Experimentation to return flag decisions for a user. The flag decision includes the status if the flag is enabled or disabled and the 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 these methods:

C# –

Go –

Java –

JavaScript (Node) –

Python –

Ruby –

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:

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: