ABToast is a simple A/B Testing app that is developed in django. This app implements the Django Session functionality to achieve the goal.
ABToast requires Django to run.
Install ABToast from pip
$ pip install django-abtoastOR, Get ABToast locally
$ git clone https://github.com/htadg/ABToast.git ABToast
$ cd ABToast/
$ python setup.py installAdd ABToast to INSTALLED_APPS
INSTALLED_APPS= (
# Django Default Apps'django.contrib.admin',
'...',
# ABToast'ABToast',
)Add ABToast.middleware.ABMiddleware to the project middlewares
MIDDLEWARE_CLASSES= (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'...',
# Custom Middleware'ABToast.middleware.ABMiddleware',
)Migrate the database and create admin account
$ python manage.py makemigrations
$ python manage.py migrate
$ python manage.py createsuperuserNow Create your own new Tests in the Database
Note: You can also create New Experiment and Tests from the Django Admin Panel
fromdatetimeimportdatetimefromdateutil.relativedeltaimportrelativedeltafromABToast.modelsimportExperiment, Test# Starting the Experiment from todaystart_date=datetime.now()
# End Date for the Experiment# Experiment runs for two monthsend_date=start_date+relativedelta(months=+2)
# Initial Traffic Redirect for the first variantinitial_traffic=50# 50%# Create an Experimentexp=Experiment.objects.create(name="Homepage Test", template_name="registrations/signup.html", goal="registrations/success", start=start_date, end=end_date, cancelled=False)
# Create two variations of the homepage.# Currently User can only create two Test instances for a particular Experiment# which means currently user can run A/B Testing on only two variants of a Page# One Test for the original templateTest.objects.create(template_name="registrations/signup.html", experiment=exp)
# Other Test for the New VariantTest.objects.create(template_name="registrations/new_signup.html", experiment=exp)Now You can run A/B Test on a view
defhome(request, template_name="registrations/signup.html"):
try:
template_name=request.ab.run(template_name)
exceptTemplateDoesNotExist:
passreturnrender_to_response(template_name)Want to contribute? Great!
Do the necessary changes that you feel and send a pull request.
- Multivariate Testing
- Add Graphical Information
- Add Bayesian Formula for the Conversion Rates
MIT
Free Software, Hell Yeah!