Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit 57877f1

Browse files
authored
Add documentation for 0.1.9 (#27)
* Add documentation for 0.1.9 * Update docs for 0.1.9 * wip * upd * up
1 parent a05997b commit 57877f1

File tree

3 files changed

+45
-54
lines changed

3 files changed

+45
-54
lines changed

README.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,9 @@ MIDDLEWARE = [
3636

3737
## Getting started
3838

39-
Add settings for the experiments:
39+
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 for that experiment is 1 which is the experiment variant with the alias "new_design" that you created. Note: The experiment cookie only works in DEBUG mode and is used to avoid interacting with the session and testing the experiment variants via the Django admin.
4040

41-
- id: Experiment ID required to identify variants for the experiment in templates
42-
- alias: Alias for the experiment ID, optional useful for clarity in templates when accessing experiment variants by key
43-
- variant_aliases: Aliases for each variant, each index represents a Optmize Experiment variant
44-
45-
```py
46-
# django-google-optimize
47-
GOOGLE_OPTIMIZE_EXPERIMENTS = [
48-
{
49-
"id": "utSuKi3PRbmxeG08en8VNw",
50-
"alias": "redesign",
51-
"variant_aliases": {0: "old_design", 1: "new_design"},
52-
}
53-
]
54-
```
55-
56-
Now you can access the experiment in templates:
41+
Now you can access the experiment in templates by the experiment alias and the variant alias:
5742

5843
```django
5944
{% if request.google_optimize.redesign == "new_design" %}

docs/configuration.md

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
11
# Configuration
22

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:
44

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
88

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

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

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 %}
2231
```
2332

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 %}
4239
```
4340

44-
## Notes
41+
Instead of by variant alias:
4542

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+
```
4748

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+
```

docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Usage in templates
44

5-
If you are redesigning major changes then you maybe would like to have two different templates. You can create a file that is called `jobs/xyz.html` that target two different files based on the experiment variant.
5+
If you are redesigning major changes then you maybe would like to have two different templates. You can create a file that is called `jobs/xyz.html` that include two different files based on the experiment variant.
66

77
`jobs/xyz.html`
88

0 commit comments

Comments
 (0)