Skip to main content


Optimizely Knowledge Base

Optimizely snippet: One line of JavaScript to run Optimizely on your site

This article will help you:
  • Learn about the Optimizely snippet from a non-technical perspective and how Optimizely works
  • Connect to resources about the snippet

Optimizely creates experiments on your site by executing a one-line JavaScript snippet that contains your unique Project ID. Once you implement the snippet, you can start building experiments and campaigns on your site. This snippet automatically updates to run any experiment you create in the Editor. You don’t have to change a thing.

Here's how to set up the snippet.

How Optimizely works: Non-technical explanation

How does Optimizely work, without getting into a technical explanation? Simple: Optimizely allows you to perform A/B testing (also known as split testing), and multivariate testing across your entire technology stack. In Optimizely, these are called experiments.

Experiments that you perform on your website and mobile web are executed via a one-line JavaScript snippet. This single line of code loads Optimizely on your site and changes the experience for visitors who are randomly bucketed into "variations." Other visitors will see a "baseline" or "original" experience. Optimizely helps you compare these different variations of an experience and determine which leads to a better user experience and more conversions.

The snippet handles how those changes execute for visitors to your site. Each snippet lives in a project in your Optimizely account. The project is a space where you'll build and manage experiments and track the results. ​​​​​​

If your account uses custom snippets, you might have more than one snippet listed in your projects.

Optimizely collects data on your visitors and conversions and runs them through our Stats Engine to show you which variations were winners or losers, compared to your baseline, so that you can make decisions about which changes to implement permanently on your site.

Here's a quick visual of how the process works:

If you're experimenting with your mobile app or across your technology stack, Optimizely runs through a software development kit (SDK). You can learn more about our SDKs on our developer site.

How else can you use Optimizely? In addition to A/B and multivariate testing, you can: