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 Full Stack.

Give your project a name and description and 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

Give your new test a unique Experiment Key. For this guide, we'll use the experiment key my_experiment.

Give test a unique experiment key

Skip the experiment traffic allocation (leave at the default of 100%), and create your variation keys.

Note:

  • If you enter a key that is already in use, the user interface notifies you and prompts you to enter a different key.
  • You will use the experiment key in your code.

> 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 experiment 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. 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'll 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 Save to Experiment. Metric options: Increase in unique conversions per visitor for my_conversion event

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

> Save the experiment

Click Create Experiment to finish.

Click Create Experiment to finish

4. Start the experiment

To allocate traffic and see experiment results, you’ll need to start the experiment. Click the 3 dots to the right of the experiment you want to start. Choose the defined environment you want your experiment to run in and click Run for the environment you want to start.

For more information and instructions on how to use Environments, see Use environments to QA your experiment code

Environment Settings

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. The object 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.

Here's how to get your Optimizely project's datafile.

7. Split the 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 universally unique identifier (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 the results

On the Optimizely Experiments dashboard, click Results for the experiment. 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 whether there is a winning variation.

Start experimenting!

Congratulations on walking through your first Optimizely test!

As a next step, we recommend reviewing the resources below:

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