roundrobin-ab
v0.0.3
Published
A round robin a/b testing library for node.
Downloads
5
Readme
#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);