If this error persists, please let us know at our support page.
Our engineering team has been notified.
Manage new features and run experiments on new algorithms, pricing, redesigns, new architectures, marketing campaigns, and more.
Run experiments and launch new features in your iOS or Android apps to improve engagement and retention.
Run experiments in your Apple TV or Android TV channels to drive more video engagement and expand your subscriber base.
import optimizely
optimizely = optimizely.Optimizely(datafile)
# Activate an experiment
variation = optimizely.activate('my_experiment', 'user_123')
if variation == 'variation_a':
# Execute code for variation A
elif variation == 'variation_b':
# Execute code for variation B
else:
# Execute default code
# Track an event
optimizely.track('purchase_completed', 'user_123')
import com.optimizely.ab.Optimizely;
Optimizely optimizely = Optimizely.builder(datafile).build();
// Activate an experiment
Variation variation = optimizely.activate("my_experiment", "user_123");
if (variation != null) {
if (variation.is("variation_a")) {
// Execute code for variation A
} else if (variation.is("variation_b")) {
// Execute code for variation B
}
} else {
// Execute default code
}
// Track an event
optimizely.track("purchase_completed", "user_123");
require "optimizely"
project = Optimizely::Project.new(datafile)
# Activate an experiment
variation = project.activate('my_experiment', 'user_123')
if variation == 'variation_a'
# Execute code for variation A
elsif variation == 'variation_b'
# Execute code for variation B
else
# Execute default code
end
# Track an event
project.track('purchase_completed', 'user_123')
var optimizely = require('optimizely-server-sdk');
var optimizely = optimizely.createInstance({ datafile: datafile });
// Activate an experiment
var variation = optimizely.activate('my_experiment', 'user_123');
if (variation === 'variation_a') {
// Execute code for variation A
} else if (variation === 'variation_b') {
// Execute code for variation B
} else {
// Execute default code
}
// Track an event
optimizely.track('purchase_completed', 'user_123');
#import <OptimizelySDKiOS/OptimizelySDKiOS.h>
OPTLYManager *manager = [OPTLYManager init:^(OPTLYManagerBuilder * _Nullable builder) {
builder.projectId = @"projectId";
}];
// Asynchronously initialize the Optimizely client
[manager initializeWithCallback:^(NSError * _Nullable error, OPTLYClient * _Nullable client) {
// Activate an experiment
OPTLYVariation *variation = [client activate:@"my_experiment" userId:@"user_123"];
if ([variation.variationKey isEqualToString:@"variation_a"]) {
// Execute code for variation A
}
else if ([variation.variationKey isEqualToString:@"variation_b"]) {
// Execute code for variation B
}
else {
// Execute default code
}
// Track an event
[client track:@"purchase_completed" userId:@"user_123"];
}];
import OptimizelySDKiOS
let optimizelyManager = OPTLYManager.init {(builder) in
builder!.projectId = "projectId"
}
// Asynchronously initialize the Optimizely Client
manager?.initialize(callback: { [weak self] (error, client) in
// Activate an experiment
let variation = client?.activate("my_experiment", userId: "user_123")
if (variation?.variationKey == "variation_a") {
// Execute code for variation A
}
else if (variation?.variationKey == "variation_b") {
// Execute code for variation B
}
else {
// Execute default code
}
// Track an Event
client?.track("purchase_completed", userId: "user_123")
})
import com.optimizely.ab.android.sdk.OptimizelyClient;
OptimizelyClient optimizelyClient = optimizelyManager.getOptimizely();
// Activate an experiment
Variation variation = optimizelyClient.activate("my_experiment", "user_123");
if (variation != null) {
if (variation.is("variation_a")) {
// Execute code for variation A
} else if (variation.is("variation_b")) {
// Execute code for variation B
}
} else {
// Execute default code
}
// Track an event
optimizelyClient.track("purchase_completed", "user_123");
use Optimizely\Optimizely;
// Initialize an Optimizely client
$optimizelyClient = new Optimizely($datafile);
// Activate an experiment
$variation = $optimizelyClient->activate('my_experiment', 'user_123');
if ($variation == 'variation_a') {
// Execute code for variation A
} elseif ($variation == 'variation_b') {
// Execute code for variation B
} else {
// Execute default code
}
// Track an event
$optimizelyClient->track('purchase_completed', 'user_123');
using OptimizelySDK;
// Initialize an Optimizely client
Optimizely OptimizelyClient = new Optimizely(datafile);
// Activate user in an experiment
var variation = OptimizelyClient.Activate("my_experiment", userId);
if (variation != null)
{
if (variation == "control")
{
// Execute code for variation A
}
else if (variation == "treatment")
{
// Execute code for variation B
}
}
else
{
// Execute default code
}
// Track conversion event
OptimizelyClient.Track("my_conversion", userId);
var optimizely = require('optimizely-client-sdk');
// Initialize an Optimizely client
var optimizelyClientInstance = optimizely.createInstance({ datafile: datafile });
// Alternatively, if you don't use CommonJS or npm, you can install the minified snippet and use the globally exported varible as follows
var optimizelyClientInstance = window.optimizelyClient.createInstance({ datafile: datafile });
// Activate user in an experiment
var variation = optimizelyClientInstance.activate("my_experiment", userId);
if (variation === 'control') {
// Execute code for variation A
} else if (variation === 'treatment') {
// Execute code for variation B
} else {
// Execute default code
}
// Track conversion event
optimizelyClientInstance.track("my_conversion", userId);
Full Stack has opened up new doors for our business. Any time we deploy something new in our product, we do it as a test to measure conversion and revenue impact, ensuring every change to the customer experience is a positive one.
Colin Gardiner, VP of Product and Analytics, Tripping.comRead Case Study![]()
Try Optimizely free for 30 days
You can get the very best of Optimizely without spending a dime.
Try it out for 30 days, on us.
Something went wrong
If this error persists, please let us know at our support page.
Our engineering team has been notified.
Contact Sales
Please tell us about yourself and your company (all fields required):
Thank you
Create a developer account
Get a free account with full access to Optimizely's APIs and SDKs.
Thank you