• Stars
    star
    1,351
  • Rank 33,450 (Top 0.7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A/B testing framework

Abba

Abba is a simple a/b testing self-hosted framework built to help improve conversion rates on your site.

  • Simple JavaScript API
  • Multi variant support
  • Filter results by date and browser

Screenshot

Setup

Requirements:

  • Ruby 1.9.3
  • Mongo

The default username and password are guard / llama. Change these in config.yml or set the environment variables ABBA_USERNAME and ABBA_PASSWORD, unless you want everybody to access your test results. The environment variables have precedence over the config file. SSL is required in an production environment by default.

To run locally:

bundle install
thin start

Heroku 10 seconds setup

git clone git://github.com/maccman/abba.git && cd abba
heroku create
heroku addons:add mongolab:sandbox
git push heroku master
heroku open

The default username and password are guard / llama.

A/B testing API

First include abba.js using a script tag. The host of this url will need to point to wherever you deployed the app.

<script src="//localhost:4050/v1/abba.js"></script>

Then call Abba(), passing in a test name and set up the control test and variants.

<script>
  Abba('test name')
    .control('test a', function(){ /* ... */ })
    .variant('test b', function(){ /* ... */ })
    .start();
</script>

The control is whatever you're testing against, and is usually the original page. You should only have one control (and the callback can be omitted).

The variants are the variations on the control that you hope will improve conversion. You can specify multiple variants. They require a variant name, and a callback function.

When you call start() Abba will randomly execute the control or variants' callbacks, and record the results server side.

Once the user has successfully completed the experiment, say paid and navigated to a receipt page, you need to complete the test. You can do this by invoking complete().

<script>
  // On successful conversion
  Abba('test name').complete();
</script>

TLDR example

<script src="//my-abba.herokuapp.com/v1/abba.js"></script>

<script>
  Abba('Checkout')
    .control()
    .variant('Text: Complete Purchase', function(){
      $('form button').text('Complete Purchase');
    })
    .variant('Color: green', function(){
      $('form button').css({background: 'green'});
    })
    .start();
</script>

You can find a more complete example under ./public/test.

Options

Persisting results

If set the persist option to true, then the experiment won't be reset once it has completed. In other words, that visitor will always see that particular variant, and no more results will be recorded for that visitor.

<script>
  Abba('Pricing', {persist: true}).complete();
</script>

Weighting

You can set a variant weight, so some variants are used more than others:

Abba('My Checkout')
  .control('Control', {weight: 20})
  .variant('Variant 1', {weight: 3}, function(){
    $('#test').text('Variant 1 was chosen!');
  })
  .variant('Variant 2', {weight: 3}, function(){
    $('#test').text('Variant 2 was chosen!');
  })
  .start();

In the case above, the Control will be invoked 20 times more often than the other variants.

Flow control

You can continue a previously started test using continue().

Abba('My Checkout')
  .control()
  .variant('Variant 1', function(){
    $('#test').text('Variant 1 was chosen!');
  })
  .variant('Variant 2', function(){
    $('#test').text('Variant 2 was chosen!');
  })
  .continue();

Nothing will be recorded if you call continue() instead of start(). If a variant hasn't been chosen previously, nothing will be executed.

You can reset tests using reset().

Abba('My Checkout').reset();

Lastly, you can calculate the test that you want to run server side, and just tell the JavaScript library which flow was chosen.

Abba('My Checkout').start('Variant A')

Links

If you're triggering the completion of a test on a link click or a form submit, then things get a bit more complicated.

You need to ensure that tracking request doesn't get lost (which can happen in some browsers if you request an image at the same time as navigating). If the link is navigating to an external page which you don't control, then you have no choice but to cancel the link's default event, wait a few milliseconds, then navigate manually:

<script>
  $('body').on('click', 'a.external', function(e){
    // Prevent navigation
    e.preventDefault();
    var href = $(this).attr('href');

    Abba('My Links').complete();

    setTimeout(function(){
      window.location = href;
    }, 400);
  });
</script>

That's far from ideal though, and it's much better to place the tracking code on the page you're going to navigate to. If you have control over the page, then add the following code that checks the URL's hash.

<script>
  if (window.location.hash.indexOf('_abbaTestComplete') != -1) {
    Abba('My Links').complete();
  }
</script>

Then add the hash to the link's URL:

<a href="/blog#_abbaTestComplete">

Credits

Thanks to the following projects:

More Repositories

1

juggernaut

[DEPRECATED] Realtime server push with node.js, WebSockets and Comet
JavaScript
1,626
star
2

monocle

Link and news sharing
Ruby
1,453
star
3

holla

Holla! - Rich JavaScript Application
JavaScript
1,069
star
4

jquery.magicmove

Animate DOM transitions.
JavaScript
644
star
5

bowline

Ruby/JS GUI and Binding framework (deprecated)
Ruby
637
star
6

stylo

Spine/CoffeeScript example GUI designer
JavaScript
526
star
7

saasy

Rails SaaS and SSO solution
Ruby
523
star
8

gfx

CSS3 3D animation library
JavaScript
511
star
9

nestful

Simple Ruby HTTP/REST client with a sane API
Ruby
505
star
10

ace

Sinatra for Node
CoffeeScript
461
star
11

supermodel

Ruby in-memory models
Ruby
367
star
12

acts_as_recommendable

Collaborative Filtering for Rails
Ruby
324
star
13

book-assets

Files for the O'Reilly book JavaScript Web Applications
JavaScript
310
star
14

go

go
Ruby
257
star
15

trevi

An opinionated Sinatra app generator
Ruby
251
star
16

flarevideo

HTML5 & Flash Video Player
JavaScript
243
star
17

spine.todos

A Backbone alternative idea
JavaScript
239
star
18

hermes

Messaging re-invented
Ruby
206
star
19

motivation

New Chrome tab page showing your age
JavaScript
197
star
20

juggernaut_plugin

Realtime Rails
JavaScript
195
star
21

spine.contacts

Spine demo contact manager
CoffeeScript
182
star
22

sprockets-commonjs

Adds CommonJS support to Sprockets
Ruby
179
star
23

macgap-rb

Generator for MacGap
Objective-C
159
star
24

sinatra-blog

A example Sinatra blog
Ruby
157
star
25

headsup

A simple Heads Up display
Ruby
145
star
26

catapult

A Sprockets/Rack build tool
Ruby
139
star
27

remail

RESTful email for Rails
Ruby
138
star
28

spine.rails3

Sample app demonstrating Spine and Rails integration
Ruby
130
star
29

bowline-twitter

Bowline Twitter client
JavaScript
112
star
30

wysiwyg

CoffeeScript
104
star
31

sinatra-pubsub

Push & Streaming for Sinatra.
Ruby
99
star
32

push-mac

Objective-C
94
star
33

stitch-rb

Stitch ported to Ruby
Ruby
93
star
34

dhash

Compare image similarity with a dhash
Ruby
93
star
35

101-school

AI generated courses
TypeScript
88
star
36

ichabod

Headless JavaScript testing with WebKit
JavaScript
85
star
37

colorcanvas

JavaScript
83
star
38

roauth

*Simple* Ruby OAuth library
Ruby
82
star
39

push

Ruby
81
star
40

juggernaut_gem

Realtime Rails
Ruby
79
star
41

spine.mobile

Spine Mobile Framework
CoffeeScript
77
star
42

super.js

Simple JavaScript framework for building RIAs (with jQuery)
JavaScript
64
star
43

oped

Email based diary
Ruby
57
star
44

remail-engine

RESTful email for Rails - see http://github.com/maccman/remail
Python
48
star
45

syncro

Synchronize state across remote clients.
Ruby
47
star
46

spine.mobile.currency

Spine Mobile currency convertor example
CoffeeScript
46
star
47

sourcemap

Ruby library for using Source Maps
Ruby
43
star
48

superapp

JavaScript state machine and class abstraction for building RIAs (deprecated! - use http://github.com/maccman/super.js)
JavaScript
31
star
49

sprockets-source-url

Adds @sourceURL support to Sprockets
Ruby
30
star
50

spine.infinite

Infinite scrolling with Spine & Rails
JavaScript
29
star
51

bowline-desktop

wxWidgets/Ruby/Webkit framework for Bowline apps
C++
28
star
52

ymockup

UI mockups using HTML and CSS
JavaScript
28
star
53

supermodel-js

SuperModel in JavaScript (deprecated! - use http://github.com/maccman/super.js)
JavaScript
26
star
54

zombies

A Facebook/Spine game.
Ruby
24
star
55

quora2

Redesigning Quora's interface, turning it into a JavaScript web application powered by Spine.
JavaScript
21
star
56

spine.mobile.contacts

Example Spine Mobile App
CoffeeScript
20
star
57

humanapi

Ruby
20
star
58

request-profile

API to access autocomplete data
JavaScript
19
star
59

gwo

Rails plugin integrating Google Web Optimizer for AB tests
Ruby
18
star
60

cft

CoffeeScript
17
star
61

jquery.upload.js

Upload files using Ajax
JavaScript
17
star
62

spine.realtime

Realtime Spine app with Rails
Ruby
15
star
63

rbyte

Byte compile Ruby 1.9.1 files and "require" support for loading compiled files.
Ruby
14
star
64

phonegap

Gem for building PhoneGap apps
Shell
13
star
65

segment-hooks

Trigger arbitrary JavaScript from Segment.com events
JavaScript
13
star
66

spine.mobile.workout

Spine Mobile Workouts Example
CoffeeScript
11
star
67

restful_email

AppEngine that provides a RESTful interface to sending emails (decrep - use http://github.com/maccman/remail)
Python
10
star
68

csbook

CoffeeScript
10
star
69

statster

Merb Web Analytics
Ruby
9
star
70

rack-modulr

Use CommonJS modules in your Rack/Rails applications
9
star
71

blossom

Demonstration chat app
JavaScript
9
star
72

dtwitter

Distributed Twitter
9
star
73

canonical

Rails plugin providing helper for canonical URLs
8
star
74

jquery.drop.js

jQuery lib abstracting the drag/drop API
JavaScript
8
star
75

alexmaccaw

Portfolio
Ruby
8
star
76

omniauth-humanapi

OmniAuth strategy for HumanAPI.
Ruby
8
star
77

the-managers-handbook

JavaScript
8
star
78

syncro-js

JavaScript library for Syncro
JavaScript
8
star
79

less-rb

Less using ExecJS
Ruby
7
star
80

bowline-bundler

Specialized version of the Bundler gem for Bowline apps
Ruby
6
star
81

spine.tutorials

Spine tutorials (DEPRECATED - use http://spinejs.com)
JavaScript
6
star
82

serveup

JavaScript
5
star
83

gdata

Recent clone of http://code.google.com/p/gdata-ruby-util (with Ruby 1.9 support)
Ruby
5
star
84

package-jquery

JavaScript
5
star
85

package-jquery-ui

JavaScript
4
star
86

node-twitter-stream

Twitter Streaming API Library for Node.js
JavaScript
4
star
87

jquery.tmpl

jQuery.tmpl for Hem
JavaScript
4
star
88

counterman

Ruby
4
star
89

monocle-assets

Ruby
4
star
90

jlink

jQuery data binding library - bind objects to HTML elements
JavaScript
4
star
91

cloudflare-r2-edge

TypeScript
4
star
92

super.todos

Port of Backbone.js Todos to Super
JavaScript
4
star
93

jeco

jQuery extension to eco
CoffeeScript
3
star
94

invoices

Test Spine app
JavaScript
3
star
95

like-detector

TypeScript
3
star
96

bp-p2p

Browser Plus P2P
Ruby
3
star
97

renoir

Simple Canvas physics engine using Verlet Integration
JavaScript
3
star
98

hnv2

Hacker News V2
CoffeeScript
3
star
99

elb-nginx-vhosts

Shell
2
star
100

socialmod

Ruby/Python/PHP client libs
PHP
2
star