roundrobin-ab

0.0.3 • Public • Published

Round Robin

A simple round robin a/b testing library for node.

Install

npm install roundrobin-ab

Create a Test

var robin = require('roundrobin-ab');

Give it a name and a set of experiences.

Each experience has an id, split percentage, and (optionally) associated data.

Make sure the split percentages equal 100%.

var fiftyFiftyTest = new robin.Test('fiftyFifty', [new robin.Experience('a', 50, optionalData), new robin.Experience('b', 50, optionalData)]);

Retrieve an Experience

var experience = fiftyFiftyTest.getExperience();

If you want to send visitors to the same experience they have visited before, pass session and setSession variables.

session is the current value of the visitor's session. setSession is a function that takes an object and stores it somewhere in the visitor's session.

var experience = fiftyFiftyTest.getExperience({
    session: request.signedCookies.experiences,
    setSession: function(experiences) {
        response.cookie('experiences', experiences);
    }
});

Do Something

if (experience.id === 'a') {
	//do version a
} else { 
	//do version b
}

console.log(experience.id, experience.data);

Package Sidebar

Install

npm i roundrobin-ab

Weekly Downloads

3

Version

0.0.3

License

none

Last publish

Collaborators

  • jperl