An A/B split test library for persisting split choices
npm install split-testA support library to simplify split testing. We have a repository of working examples you can reference in https://github.com/mobify/adaptivejs-split-test-examples
Install split-test using npm:
$ npm install split-test --save-dev
``js`
var splitTest = SplitTest.init(
{
'A': 0.4,
'B': 0.5,
'C': 0.1
},
{
namespace: 'foo'
}
);
`js`
splitTest.getChoice();
Adds a script to a custom container.
| Parameter name | Type | Description |
|----------------|-------------|-----|
| value | Object | The split condition |
| options | Object | The setup parameters |
`js`
var splitTest = SplitTest.init(
{
'A': 0.4,
'B': 0.5,
'C': 0.1
},
{
namespace: 'foo',
cookieDomain: 'http://www.foo.com',
lifetime: 15
}
);
Available options
| Options | Type | Description |
|----------------|-------------|------|
| namespace | String | The namespace of the cookie to prevent conflict between cookie names |
| cookieDomain | String | The domain of this cookie. Default to the hostname |
| lifetime | Integer (milliseconds) | The lifetime of the cookie. Default to 30 days. |
Returns the split choice key.
`js`
// This returns either 'A', 'B', or 'C'
var choice = splitTest.getChoice();$3
Manually sets the split choice.
| Parameter name | Type | Description |
|----------------|-------------|-----------|
| value | String | split choice key |
`js
splitTest.setChoice('C');
// This return 'C'
splitTest.getChoice();
`
* Make your code changes and create a pull-request
* Ensure the tests still work (grunt test`)
* Get your change reviewed and :+1:'ed
* 1.0.0: Remove bower dependencies and dist folder, distribute on npm
* 0.0.1: Initial commit
Talk to @jansepar or @dbader.