|
1 | 1 | # Configuration |
2 | 2 |
|
3 | | -The configuration is a list of dicts and each dict consists of three fields, one being mandatory and the other two being optional: |
| 3 | +You can configure the Google Optimize experiments via the Django admin panel. There are three objects that you can add: |
4 | 4 |
|
5 | | -- id(string, required): Experiment id required to identify each experiment in the cookie set by Google. |
6 | | -- alias(string, optional): Alias for the experiment id, useful for clarity when accessing experiment variants by key. |
7 | | -- variant_aliases(dict, optional): Aliases for each variant, consist of key-value variables. The key represents the index for each experiment variant. The value is the alias for the variant. Check your Google Optimize experiment to see which index represents what experiment variant. |
| 5 | +- Google Experiment. |
| 6 | +- Experiment Variant |
| 7 | +- Experiment Cookie |
8 | 8 |
|
9 | | -## Single experiment |
| 9 | +The Google Experiment object contains of an experiment id and an optional alias which can used to alternatively reference the experiment in code. |
10 | 10 |
|
11 | | -For a single experiment the settings could be the following: |
| 11 | +The Experiment Variant is optional and it is used to give each experiment variant an alias for easier usage in templates/views. If not added, the returned variant will be the index of the variant in the Google Optimize experiment cookie(_gaexp). |
12 | 12 |
|
13 | | -```py |
14 | | -# django-google-optimize |
15 | | -GOOGLE_OPTIMIZE_EXPERIMENTS = [ |
16 | | - { |
17 | | - "id": "utSuKi3PRbmxeG08en8VNw", |
18 | | - "alias": "redesign", |
19 | | - "variant_aliases": {0: "old_design", 1: "new_design"}, |
20 | | - } |
21 | | -] |
| 13 | +The Experiment Cookie is optional and it is only used in DEBUG mode. It aids in overriding or adding an experiment to the browser cookie(_gaexp). Replaces any interaction with the browser session while developing, making it possible to test out all your variants via the Django admin. |
| 14 | + |
| 15 | +## Sample Configuration |
| 16 | + |
| 17 | +Without an Google Experiment alias you will have to reference your experiment by id: |
| 18 | + |
| 19 | +```python |
| 20 | + {% if request.google_optimize.k123ladwq == 0 %} |
| 21 | + {% include "jobs/xyz_new.html" %} |
| 22 | + {% endif %} |
| 23 | +``` |
| 24 | + |
| 25 | +Instead of by experiment alias: |
| 26 | + |
| 27 | +```python |
| 28 | + {% if request.google_optimize.redesign_header == 0 %} |
| 29 | + {% include "jobs/xyz_new.html" %} |
| 30 | + {% endif %} |
22 | 31 | ``` |
23 | 32 |
|
24 | | -## Multiple experiments |
25 | | - |
26 | | -For multiple experiments the settings could be the following: |
27 | | - |
28 | | -```py |
29 | | -# django-google-optimize |
30 | | -GOOGLE_OPTIMIZE_EXPERIMENTS = [ |
31 | | - { |
32 | | - "id": "3x8_BbSCREyqtWm1H1OUrQ", |
33 | | - "alias": "redesign_page", |
34 | | - "variant_aliases": {0: "old_design", 1: "new_design"}, |
35 | | - }, |
36 | | - { |
37 | | - "id": "7IXTpXmLRzKwfU-Eilh_0Q", |
38 | | - "alias": "redesign_header", |
39 | | - "variant_aliases": {0: "old_header", 1: "new_header"}, |
40 | | - }, |
41 | | -] |
| 33 | +Without an variant alias you will have to reference your variant by index as: |
| 34 | + |
| 35 | +```python |
| 36 | + {% if request.google_optimize.redesign_header == 0 %} |
| 37 | + {% include "jobs/xyz_new.html" %} |
| 38 | + {% endif %} |
42 | 39 | ``` |
43 | 40 |
|
44 | | -## Notes |
| 41 | +Instead of by variant alias: |
45 | 42 |
|
46 | | -If you do not set the alias you'll have to access the experiment variant by the Google Optimize id for the experiment. |
| 43 | +```python |
| 44 | + {% if request.google_optimize.redesign_header == "New Background Color" %} |
| 45 | + {% include "jobs/xyz_new.html" %} |
| 46 | + {% endif %} |
| 47 | +``` |
47 | 48 |
|
48 | | -If you do not set the variant alias for a variant the index will be the variant returned. |
| 49 | +If you do not use the Experiment Cookie object when testing locally make sure to add the `_gaexp` cookie to the session: |
| 50 | + |
| 51 | +```txt |
| 52 | +Cookie Name: _gaexp |
| 53 | +Cookie Value GAX1.2.{experiment_id}.18147.{active_variant_index} |
| 54 | +``` |
0 commit comments