Skip to main content

Django-google-optimize is a reusable Django application designed to make running server side Google Optimize A/B test easy.

Project description

Django-google-optimize

Lint Test Coverage Supported Python versions PyPI Version

Django-google-optimize is a Django application designed to make running Google Optimize A/B tests easy.

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:

<nav class="navbar navbar-expand-lg navbar-dark
{% if request.google_optimize.redesign == "new_design" %} navbar-redesign{% endif %}">

Note: The experiment cookie only works in DEBUG mode and is used to avoid interacting with the session to add the _gaexp cookie making it possible to test the experiment variants through the Django admin.

Full documentation can be found here.

Documentation and Support

More documentation can be found in the docs directory or read online. Open a Github issue for support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-google-optimize-0.2.3.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

django_google_optimize-0.2.3-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page