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 reusable Django application designed to make running server side Google Optimize A/B test easy.

Installation

Install django-google-optimize with pip:

pip install django-google-optimize

Add the application to installed django applications:

DJANGO_APPS = [
    ...
    "django_google_optimize",
    ...
]

Add the context processor:

"context_processors": [
    ...
    "django_google_optimize.context_processors.google_experiment",
    ...
]

Getting started

Add settings for the experiments:

  • id: Experiment ID required to identify variants for the experiment in templates
  • alias: Alias for the experiment ID, optional useful for clarity in templates when accessing experiment variants by key
  • variant_aliases: Aliases for each variant, each index represents a Optmize Experiment variant
# django-google-optimize
GOOGLE_OPTIMIZE_EXPERIMENTS = [
    {
        "id": "utSuKi3PRbmxeG08en8VNw",
        "alias": "redesign",
        "variant_aliases": {0: "old_design", 1: "new_design"},
    }
]

Now you can access the experiment in templates:

{% if 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 google_optimize.redesign == "new_design" %} navbar-redesign{% endif %}">

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.

Files for django-google-optimize, version 0.1.7
Filename, size File type Python version Upload date Hashes
Filename, size django_google_optimize-0.1.7-py3-none-any.whl (4.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-google-optimize-0.1.7.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page