Get started quickly

Run your first experiment in minutes!

This guide walks through running a basic Optimizely experiment using our SDK.

1. Create an Optimizely account

You’ll need access to Optimizely X to use the SDK. Create a free developer account to get access or contact your Customer Success Manager to have it enabled on your company’s plan.

2. Create a project

Create a new project in the Optimizely web dashboard and click Create Project.

Give your project a name and description, and then click Create Project.

Name and describe your project

3. Create an experiment

From your new project's home page, select Create New… > Experiment to configure your first experiment.

Select Create New - Experiment

On the following screen, you'll configure the details of the experiment.

> Create an experiment key

First, give your new experiment an Experiment Key. The experiment key is a unique identifier for each experiment. You'll use this key in your code. For this guide, we'll use the experiment key my_experiment.

Give experiment a unique experiment key

Next, skip the experiment traffic allocation (100%), and create your variation keys.

> Create variation keys

Each version of an experience within your webpage or app is called a variation, and each variation key is the identifier for the code that powers each experience. In this example, we demonstrate how to create an A/B test, so there will be two variations: the original version and the new version. We're calling the original version control and the new version treatment.

Set variation keys: control and treatment

> Create an event

We'll measure the success of our test by creating an event and a tracking it in a metric. Every Optimizely experiment needs at least one metric.

Under Metrics, click Create New Event and give it a unique event key on the following screen.

Click 'Create New Event'

We're using the example event key my_conversion. Note that Optimizely generates the event tracking code that you can use to report each event from within your code.

Give your new event a unique 'event key'

Click Create Event when you are satisfied. You should then see your newly-created event key under Events.

Click the Create Event button

> Create a metric

Create your metric by describing how you want to measure and report the results of your new event.

Click your new event (my_conversion). Click 'my conversion'

Set the metric options ("Increase in unique conversions per visitor for my_conversion event.") and click Add to Experiment. Metric options: Increase in unique conversions per visitor for my_conversion event

After you've added the metric, note how Optimizely generates the code for you. Your metrics are set

> Save experiment

Click Create Experiment to finish.

Click Create Experiment to finish

4. Start the experiment

In order to allocate traffic and see experiment results you’ll need to start the experiment. Do this by clicking on the 3 dots to the right of the experiment you wish to start and selecting Start Experiment.

5. Install the SDK

6. Create an Optimizely client

After installing the SDK, you're ready to create an Optimizely client.

An Optimizely Client is an object that represents the state of your Optimizely project within your application. It gets this information from your project's datafile, a JSON representation of your project's configuration details. The datafile contains all of the instructions needed to activate experiments and track events in your code without requiring any blocking network requests.

You can get your Optimizely project's datafile by using its CDN link. Go to Settings > Datafile in the Optimizely web app.

Your datafile's CDN link found in Settings > Datafile

7. Split traffic

To get statistically-significant results from your experiments, your users need to be randomly assigned to groups (or buckets) that determine which of your experiment's variations they are going to see. This act of assigning users to groups is often called bucketing.

The Optimizely SDK handles user bucketing for you with the .activate() function.

When provided with a user ID, the function returns a variation key and reports an impression event (sometimes called a decision point) to Optimizely. The user ID can be any string that represents a user. It can be a UUID from your system, or, if you want to anonymize your users, you can generate a random UUID. Note: the SDK does not generate UUIDs.

Further reading

8. Track events

You'll want to track your experiment's performance against metrics you've defined. Earlier, we set up one metric called my_conversion. The SDK’s .track() function will inform Optimizely of this event using the user ID and the corresponding event key. The code below will track a conversion event:

9. View results

In the Optimizely web dashboard, click Results on your experiment to see the results within a few minutes. In this example, you created two impressions and one conversion so you should see a results page similar to this:

As your experiment receives more traffic, Optimizely’s Stats Engine will determine if there is a winning variation.

Start experimenting!

Congratulations on walking through your first Optimizely experiment!

As a next step we recommend reviewing the resources below:

If you have any questions or feedback, you can submit a ticket to the developer support team. We'll be happy to assist you.