Skip to main content

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.

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:

<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.

Metadata

Release files for django-google-optimize 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-google-optimize 0.3.0
File Size Uploaded
django-google-optimize-0.3.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-google-optimize 0.3.0
File Interpreter ABI Platform
django_google_optimize-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / django-google-optimize-0.3.0.tar.gz

Download URL django-google-optimize-0.3.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
beb6a49f36b166a5aea8cf119fab52ee1e651da5a8211041c96dfa0cd64fc82f
BLAKE2b-256 checksum
How to use checksums
aad42eae51f641a5b68c19b37af2c2b477dc2c701a9c735699027285841c35d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1036-azure

Release files / django_google_optimize-0.3.0-py3-none-any.whl

Download URL django_google_optimize-0.3.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7b8e19d7e30751ebcc03396a225d2c0887515ab0bc6ad1f73bd1b3ae7371812
BLAKE2b-256 checksum
How to use checksums
9a893a984893d87f8b2681ed40fe2390ca6c060302cd55aba6a817a2a48505a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1036-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page