Simple A/B Testing Framework for client and server
CoffeeScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
spec
src
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json

README.md

Build Status Dependencies devDependencies NPM version

Laboratory

Simple A/B Testing Framework for both client and server environments.

Laboratory chooses a variant for each experiment based on a configurable probability. Use the pluggable storage interface to serve users a consistent experience after they've been assigned a variant.

$ npm install laboratory

Example Usage

Run a single Experiment:

{Experiment} = require "laboratory"

experiment = new Experiment("color")
  .variant "red", 50, "#FF0000"
  .variant "blue", 50, "#0000FF"

variant = experiment.run()
variant.name # Either red or blue
variant.value # Either FF0000 or 0000FF

Run a suite of experiments in a Laboratory:

{Laboratory} = require "laboratory"
laboratory = new Laboratory()

laboratory.addExperiment("color")
  .variant "red", 50, "#FF0000"
  .variant "blue", 50, "#0000FF"

laboratory.addExperiment("FuzzyBunnies")
  .variant "variant0", 50,
    name: "Peter Rabbit"
    type: "Wooly"
  .variant "variant1", 50,
    subject: "Briar Rabbit"
    type: "Silky"

experiment = laboratory.run("FuzzyBunnies")
experiment.value # Either Peter or Briar Rabbit

Store the results per user in browser local storage:

store = new LocalStorageStore() # not included
laboratory = new Laboratory(store)

laboratory.addExperiment /* ... */
laboratory.run /* ... */