Git Product home page Git Product logo

scenario.js's Introduction

Scenario

A lightweight A/B Testing library for use with MixPanel

View Slide

Install

<script type="text/javascript" src="mixpanel.js"></script>
<script type="text/javascript" src="scenario.js"></script>

Usage

var test = new Scenario('My Test Name')
           .test('Test A')
           .test('Test B')
           .go();

test.complete();

API

  • Scenario( String testName ): Initializes a new test and returns two functions, test, and go.
  • test( String name[, function fn] ): Adds a test variant. name is the name of the variant, and an optional function may be passed in the second parameter that will execute if the test case is chosen. In addition, the body has the test cases name added to it in the form of a slug, so "Test Case A" will be added to the body as "test-case-a"
  • go(): Rolls the dice and calls one of the variants. Returns the instance based method(s) complete.
  • complete(): Finishes the test sequence.

MixPanel Integration

MixPanel is required with Scenario.

Once the go() function has been called, the initial tracking event occurs:

mixpanel.track( "My Test Name Start" );

Shortly after a test is chosen, another tracking event occurs. This one records the test case used:

mixpanel.track("My Test Name Mid", {
    test: "Test A"
});

Once the complete() function has been called, the final tracking occurs:

mixpanel.track( "My Test Name Finish" );

Creating the Funnel

Navigate to MixPanel and click Funnels. Create a funnel that includes the testName Load, testName, and testName Finish, then click Save.

Practical Examples

var test = new Scenario( 'Homepage Signup Conversions' )
           .test( 'Home V1' )
           .test( 'Home V2' )
           .go();

signup.on('click', function(){
    test.complete();
});

This results in the body tag being appended with a css class like the following:

<body class="home-v1">

Alternatively, you can handle your test differences with JavaScript:

var test = new Scenario( 'Homepage Signup Conversions' )
           .test( 'Home V1', function(){
               // Do something optional
           })
           .test( 'Home V2', function(){
               // Do something optional
           })
           .go();

signup.on('click', function(){
    test.complete();
});

Licensing

MIT

scenario.js's People

Contributors

jakiestfu avatar

Watchers

edwardttril avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.