• Stars
    star
    153
  • Rank 241,943 (Top 5 %)
  • Language
    Python
  • Created over 15 years ago
  • Updated over 15 years ago

Reviews

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

Repository Details

A simple AB Testing app for Django!

About

Create simple A/B tests in Django by dynamically switching templates. Records unique hits and conversions to tests.

Usage

  1. Update your settings.py:

    # Add `ab` to `INSTALLED_APPS`
    INSTALLED_APPS = (
        ...
        'ab',
        )
        
    # Add `ab.middleware.ABMiddleware` to `MIDDLEWARE_CLASSES`
    MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        ...
        'ab.middleware.ABMiddleware',
    )
    
    # Add `ab.loaders.load_template_source` as your _FIRST_ `TEMPLATE_LOADERS`.
    TEMPLATE_LOADERS = (
        'ab.loaders.load_template_source',
        'django.template.loaders.filesystem.load_template_source',
        ...
    )
    
  2. Run python manage.py sync_db to create the testing tables.

  3. Create some tests in the Django admin (or like this from the command line)!

    from ab.models import Experiment, Test
    
    # Create an Experiment who's Goal is to get to the signup page!
    exp = Experiment.objects.create(name="Homepage Test", template_name="index.html", goal="/signup/")
    
    # Create three variations of the homepage.
    
    # One Test for the original template
    Test.objects.create(template_name="index.html",)
    
    # Two variations
    Test.objects.create(template_name="index_1.html", experiment=exp)
    Test.objects.create(template_name="index_2.html", experiment=exp)
    
  4. Profit.

Advanced

  1. Manually run an A/B test on a view:

    def view(request, template_name="original.html"):

       try:
           ab_template_name = request.ab.run(template_name)
       except TemplateDoesNotExist:
           ab_template_name = template_name
       
       return render_to_response(template_name)
    

Tips

Decide ahead of time what you are A/B testing - introductions of new designs are a great time to run your first test. Plan ahead of time and duplicate your templates / css / js / images so you don't have to hunt through version control to find the right ones later.

Notes

  1. The current implementation uses a thread locals to stash the request object for use in places it isn't normally available.

  2. The current implementation is not compatible with Django's built in caching.

  3. The current implementation requires you to use Django Sessions.

ToDo

  1. Add A/B aware CacheMiddleware
  2. Rethink ab.abs.AB interface.
  3. De-couple AB from request/session object? Would be interesting to run it on e-mails etc.
  4. Add a way to force the display of specific templates (for designers etc.)
  5. What if a browser has disabled cookies? What's the fallback?
  6. Add some way to ignore hits and conversions (eg. internal/logged in etc.)
  7. Expanded conversion maybe to a regex? or something else that account for variations of pages

More Repositories

1

django-paypal

A pluggable Django application for integrating PayPal Payments Standard or Payments Pro
Python
544
star
2

django_webhooks

Django WebHooks makes it easy to integrate WebHooks into your Django Project.
44
star
3

snapboard

Simple django forum application.
Python
21
star
4

django_admob

Django code for including admob ads / analytics based on the `admob` gem.
Python
15
star
5

canadian-payroll-calculator

Django application for keeping track of Canadian payroll taxes.
Python
14
star
6

ibug

Debug JavaScript on your mobile device from the comfort of your desktop browser.
JavaScript
11
star
7

master-class

Master Class is a JavaScript library that allows you to target mobile browser functionality in your stylesheet.
JavaScript
9
star
8

django_usertools

A set of basic tools for django.contrib.auth.models.User
Python
8
star
9

orko

A CLI for analysing Pull Request metadata from GitHub.
Python
8
star
10

django-testmonkey

Web interface for Django test runner.
Python
7
star
11

remote-api-clientside-js

Demo of accessing remote APIs using Javascript using JSONP, CORS and Proxying.
JavaScript
7
star
12

django-email-auth

(Yet Another) Django Email Authentication Backend
Python
6
star
13

deviceatlas

Reimagining of the Python Device Atlas API
Python
6
star
14

superstylin

Edit and update CSS from the comfort of your browser.
JavaScript
5
star
15

django-tenderize

Tender Plugin for Django
Python
5
star
16

django-mobileadsense

Django utilites for using Google AdSense for Mobile.
Python
5
star
17

betty

Betty is a command line utility for syncing static websites to S3.
JavaScript
4
star
18

pytimeout

Experiments implementing timeouts on the request/response cycle of a Python web server using Django and Gunicorn.
Python
4
star
19

jquery-domtree

jQuery Plugin for displaying an HTML DOM structure based on FireBug-Lite.
3
star
20

dpod

DropPod is a CLI for deploying private GitHub repositories to Heroku.
Python
3
star
21

jquery_ajaxupload

Ajax Upload for Jquery based on ajaxUpload plugin and ajaxFileUpload.
3
star
22

django_imagesize

Stores the sizes of images in DB.
Python
3
star
23

mrtoad

mobile sites debug you
JavaScript
3
star
24

django_zeep

Django App for pluggable for Zeep Mobile SMS API
Python
3
star
25

PhotoShop-

Not to be confused with the PhotoShopâ„¢ application, PhotoShop! uses TinEye and Shopify to turn any poster into a store.
Objective-C
3
star
26

johnboxall.github.com

JavaScript
2
star
27

clientside-js-testing

Introduction to Clientside JavaScript testing using Qunit, Phantomjs and maybe even CI!
JavaScript
2
star
28

sdfmw

Sane performance defaults for the mobile web.
JavaScript
2
star
29

django-fastregistration

One step registration
Python
2
star
30

django_kiss

A Django application for integrating KISSmetrics customer analytics
Python
2
star
31

x

X JavaScript GeoLocation Library
1
star
32

cbv

Class Based Views presentation for Django meetup!
Python
1
star