1.2.17 • Published 7 years ago

tiny-experiment v1.2.17

Weekly downloads
46
License
ISC
Repository
github
Last release
7 years ago

tiny-experiment

A lightweight utility to run split tests in your javascript application.

Quick start

1) Install

npm install tiny-experiment --save

2) Require module

var tinyManager = require('tiny-experiment');
// window.tinyManager is available now

3) Register experiments once

tinyManager.setup({
  experiments: [
    {
      experimentKey(required): 'homepageButtonStyle', // unique key
      experimentName(required): 'Homepage button style', // descriptive name for analytics

      variantNames(required): ['blue', 'red'],
      variantWeights(optional): [0.25, 0.75], // must add up to 1.0

      cached(optional): Boolean // default false, if true user will see same variant next time
      cachePeriod(optional): Number // default 7, if cached user will see same variant for X days
    },
    {
      // experiment two
    }
  ]
})

4a) Then run an experiment with variant-specific handlers

var experiment = tinyManager.getExperiment('homepageButtonStyle')

experiment
.on('blue', function() {
  // make button blue
})
.on('red', function() {
  // make button red
})
.run()

4b) You can 'run' the experiment asynchronously

experiment.on('blue', function() { ... })

someAsyncFunction(function() {
  experiment.run()
})

// or reversed in order

When an experiment is run

A segment analytics call is made with event name 'Experiment Viewed', and the properties: experimentName, variantName, variantId, and variantNames. Make your funnel with 'Experiment Viewed' (experimentName, variantName) as the start point and any other segment event as the endpoint.

To customize the default behavior when an experiment is run:

import tinyManager from 'tiny-experiment';
tinyManager.setup({
  experiments: [ ...experiments... ],
  globalCompletionHandler: function(params) {
    // do something where argument, params, has keys: experimentName, variantName, variantId, and variantNames
  }
})

Manual variant setting

http://domain.com/?experimentKey=homepageButtonStyle&variantName=blue || variantId=1

This will run the experiment with experimentKey = homepageButtonStyle, and manually set the variant as 'blue'

Angular

a directive that let's you hide/show elements without writing any javascript: https://github.com/genelee/angular-experiment

1.2.17

7 years ago

1.2.16

7 years ago

1.2.15

7 years ago

1.2.14

7 years ago

1.2.13

7 years ago

1.2.12

7 years ago

1.2.11

7 years ago

1.2.10

7 years ago

1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.55

8 years ago

1.0.54

8 years ago

1.0.53

8 years ago

1.0.52

8 years ago

1.0.51

8 years ago

1.0.5

8 years ago

1.0.42

8 years ago

1.0.41

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.21

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago