This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Optimizely API PHP SDK

2.0.0 2017-10-13 22:03 UTC

This package is not auto-updated.

Last update: 2021-10-16 03:40:55 UTC


Packagist Travis

PHP Wrapper to interact with the Optimizely API.


composer require widerfunnel/optimizely-sdk


Simply create an Optimizely object, with a valid OAuth Token in the constructor:

$optimizely = Optimizely::create($token);

If you wish to use the token based authentication, simply pass true as a second argument:

$optimizely = Optimizely::create($token, true);


// Read a project

// Create a project
    'project_name' => 'My new project'

// Update a project
$optimizely->projects()->update($projectId, [
    'project_name' => 'My new name'

// Delete a project
// Not supported by Optimizely Rest API

// List projects in account

// Activate a project

// Archive a project


// List experiments in project

// Create an experiment
    ['status' => 'Paused']

// Update an experiment
$optimizely->experiment($experimentId)->update(['edit_url' => 'newsite.com']);

// Launch an experiment

// Pause an experiment

// Resume an experiment

// Archive an experiment


// Fetch variations for a given experiment

// Create variation
$optimizely->experiment($experimentId)->createVariations('varA', [
    'weight' => 25

// Find a variation

// Update a variation
$optimizely->variation($variationId)->update(['description' => 'Control']);

// Update variation description
$optimizely->variation($variationId)->description('Variation A');

// Update variation weight

// Update variation JS component

// Pause variation

// Resume variation

// Delete a variation


// Fetch the results of an experiments

// Fetch the results of an experiments (legacy version)


// Find a schedule

// Update schedule

// Update start time of a given schedule

// Update stop time of a given schedule

// List schedules for an experiment

// List active schedules for an experiment

// List inactive schedules for an experiment

// Create a schedule for an experiment

// Start an experiment at a given time

// Stop an experiment at a given time

// Delete a schedule


// List audiences in project

// Find an audience

// Create an audience
$optimizely->project($projectId)->createAudience('My second audience');

// Update an audience
    'name' => 'My new name'

// Delete an audience
// Not supported by Optimizely Rest API


// List goals in project

// Find a goal

// Create a goal in a project
$optimizely->project($projectId)->createGoal('My new goal', 1, [
    'event' => 'My event'

// Delete a goal


// List dimensions in a project

// Find a dimension

// Create a dimension
$optimizely->project($projectId)->createDimension('My dimension');

// Update a dimension
    'name' => 'My new dimension name'

// Delete a dimension

Uploaded Lists

// List uploaded lists in project

// Find a uploaded list

// Create an uploaded list
    'List', UploadedList::TYPE_QUERY_STRING, 'csv',
    'user_id', 'uid1,uid2,uid3,uid4'

// Update an uploaded list
    'key_fields' => 'user_uid'

// Delete an uploaded list


For your contributions please be sure to read the guidelines


This is licensed under MIT