GitHub - adinhodovic/django-google-optimize: Django-google-optimize is a Django application designed to make running server side Google Optimize A/B tests easy. (original) (raw)
Django-google-optimize
Django-google-optimize is a Django application designed to make running Google Optimize A/B tests easy.
Here is a tutorial on the Google Optimize basics and how to use this Django application.
Installation
Install django-google-optimize with pip:
pip install django-google-optimize
Add the application to installed Django applications:
settings.py
INSTALLED_APPS = [ ... "django_google_optimize", ... ]
Add the middleware:
MIDDLEWARE = [ ... "django_google_optimize.middleware.google_optimize", ... ]
Getting started
Head over to the Django admin and add a new Google Optimize experiment. Add an experiment variant with the index 1 and the alias "new_design". Set the experiment cookie's active variant index to 1. Now the active variant index for that experiment is 1 which is the experiment variant with the alias "new_design" that you created.
Now you can access the experiment in templates by the experiment alias and the variant alias:
{% if request.google_optimize.redesign == "new_design" %} {% include "jobs/jobposting_list_new.html" %} {% else %} {% include "jobs/jobposting_list_old.html" %} {% endif %}
Or use it inline: