Use Optimizely alongside Sprig in order to compare & segment results based on user experiments/variations.

Optimizely is a digital experience & experimentation platform. By integrating Optimizely with Sprig, you will be able to accomplish the following:

  1. Target users/segments based on an experiment id and variation name(s)
  2. Run cross-tab analysis based on an experiment id and variation name(s)

Optimizely Supported Products:


Sprig Supported SDKs:

PlatformTriggersFiltersEvent Properties
Native iOS
Native Android
React Native

Sprig Min SDK Versions:

Please reference the table below to determine which version of the Sprig SDK your team will need to adopt in order to integrate Optimizely <> Sprig

PlatformMin SDK Version
Web2.18.3 / 2.23.1
Native iOS4.11.0
Native Android2.10.0
React NativeTBD

How to Implement:

Send all active experiments & variations


Optimizely offers two different product: Web and Full-Stack Experimentation. Based on the product you want to integrate with, you will follow separate steps to get it installed.

Optimizely Web

On web, so long as the client SDK matches or is greater than the min (2.18.3), Optimizely will work without any additional dev effort. If your SDK version does not match, you will need to request your developer to update accordingly.

Optimizely Full-Stack

This will require you to have a minimum Sprig SDK version of 2.23.1. Once you have installed that version, you will be able to have access to two new methods that will allow you to integrate.

Option 1: Passing in Optimizely Client to our SDK

This is the easiest option as we will add in a notification listener to your Optimizely client for you. What this notification listener will do is that it will listen to every time you activate an experiment, and pass the experiment and variation to Sprig.

const optimizelyClient = optimizely.createInstance({
  sdkKey: "<Your_SDK_KEY>",
optimizelyClient.onReady().then(() => {
  Sprig.integrateOptimizelyClient(optimizelyClient); // once the client is ready, pass client into Sprig

Option 2: Creating your own notification listeners

This option requires more engineer work, however, there is more flexibility and customization with this option. For this option, you will create your own notification listeners and append to your client. It's important here that you pass in with the correct object format otherwise we will not accept the data. Please see the code snippet below for an example.

You can read more about setting up Optimizely notification listeners here.

const optimizelyClient = optimizely.createInstance({
  sdkKey: "<Your_SDK_KEY>",

	}: ActivateListenerPayload) => {
    // Create this object and pass it into Sprig in line 20
	  const insertExperiment = {
	    experiments: [
	        id: experiment.id,
	        variation: variation.key,
	  Sprig.integrateOptimizely(insertExperiment, false); // you pass in the experiment/variation to Sprig and we will store and pass the data every time you track a Sprig event.

iOS or Android

Step 1: Cut & paste the snippet below into your application code base

// iOS code example: Client passed in userId and OptimizelyClient to SDK,
// Sprig SDK will assume the userId is involved in all the experiments, and send
// variations of each experiment to Sprig backend.
let optimizely = OptimizelyClient(sdkKey: "<Your_SDK_Key>")
try? optimizely.start(datafile: localDatafile,
                              doUpdateConfigOnNewDatafile: true)
 isOverride: if true, previously provided experiments in this session will be cleared and only
 the newly provided experiments will be sent to Sprig
Sprig.shared.integrateOptimizely(optimizely, userId: userId, attributes: visitorAttributes, isOverride: isOverride);
// When Optimizely finish initialization, pass in the Optimizely client to Sprig.
OptimizelyManager.builder().withSDKKey("SDK KEY HERE").build(this).also { optimizelyManager ->

Step 2: Replace with your Optimizely SDK Key
Step 3: Share your associated customer userId with Sprig (not required, but recommended)

Once you have shared your Optimizely SDK Key and the customer’s userId (not required), Sprig will automatically parse all active experiments & variations that are currently active in your application.

How to Use:

Prior to in-product targeting, please ensure you reach out to [email protected] in order to activate the integration for your respective productId

Once Optimizely has been configured for your account, you can proceed onwards and create a study OR edit an existing one.

Step 1: Enable Optimizely in Sprig's integration gallery
Step 2: Create a new study OR edit an existing one
Step 3: Fill out the question form and move on to the audience form
Step 4: In the audience form, select a trigger for “When to Send”
Step 5: Select your Optimizely Experiment attribute (see below)
Step 6: Copy and paste the corresponding experimentId from Optimizely to Sprig (see below)
Step 7: Copy and paste the corresponding value for the variation and pick a comparison operator (see below)

Please refer to our guide on how to launch a study for any questions on the survey builder


Question: Can I target multiple experiments/variations with a single study?
Answer: Yes! You can use the AND/OR targeting to support multiple experiments/variations. You can also change the comparison operator to “contains” to target more than one variation

Question: Does this work for React Native?
Answer: At this time, our Optimizely integration does not support React Native. We expect a target of Q1, 2023 to introduce React Native

Question: How do I export experiment names & variations from Sprig?
Answer: On your Summary page, navigate to responses and select the CSV download option. You should be able to see each respondent, including all qualifying experiments/variations