Skip to content

Commit 97c4a70

Browse files
committed
Add detailed docs
1 parent b68864d commit 97c4a70

File tree

1 file changed

+79
-5
lines changed

1 file changed

+79
-5
lines changed

README.rst

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
1-
.. image:: https://api.travis-ci.org/torchbox/wagtail-experiments.svg?branch=master
2-
:target: https://travis-ci.org/torchbox/wagtail-experiments
3-
41
.. image:: wagtail-experiments.png
52

63
Wagtail Experiments
74
===================
85

9-
A/B testing for Wagtail
6+
.. image:: https://api.travis-ci.org/torchbox/wagtail-experiments.svg?branch=master
7+
:target: https://travis-ci.org/torchbox/wagtail-experiments
8+
9+
**A/B testing for Wagtail**
10+
11+
This module supports the creation of A/B testing experiments within a Wagtail site. Several alternative versions of a page are set up, and on visiting a designated control page, a user is presented with one of those variations, selected at random (using a simplified version of the `PlanOut algorithm <https://facebook.github.io/planout/>`_). The number of visitors receiving each variation is logged, along with the number that subsequently go on to complete the experiment by visiting a designated goal page.
12+
1013

1114
Installation
1215
------------
1316

14-
Add ``'experiments'`` to ``INSTALLED_APPS``.
17+
To install::
18+
19+
pip install wagtail-experiments
20+
21+
and ensure that the apps ``wagtail.contrib.modeladmin`` and ``experiments`` are included in your project's ``INSTALLED_APPS``:
22+
23+
.. code-block:: python
24+
25+
INSTALLED_APPS = [
26+
# ...
27+
'wagtail.contrib.modeladmin',
28+
'experiments',
29+
# ...
30+
]
31+
32+
33+
Usage
34+
-----
35+
36+
After installation, a new 'Experiments' item is added to the Wagtail admin menu under Settings. This is available to superusers and any other users with add/edit permissions on experiments. An experiment is created by specifying a control page and any number of alternative versions of that page, along with an optional goal page. Initially the experiment is in the 'draft' status and does not take effect on the site front-end; to begin the experiment, change the status to 'live'.
37+
38+
When the experiment is live, a user visiting the URL of the control page will be randomly assigned to a test group, to be served either the control page or one of the alternative variations. This assignment persists for the user's session (according to `Django's session configuration <https://docs.djangoproject.com/en/1.10/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions>`_) so that each user receives the same variation each time. When a user subsequently visits the goal page, they are considered to have completed the experiment and a completion is logged against that user's test group. The completion rate over time for each test group can then be viewed through the admin interface, under 'View report'.
39+
40+
From the report page, an administrator can select a winning variation; the experiment status is then changed to 'completed', and all visitors to the control page are served the chosen variation.
41+
42+
Typically, the alternative versions of the page will be left unpublished, as this prevents them from appearing as duplicate copies of the control page in the site navigation. If an unpublished page is selected as an alternative, the page revision shown to users on the front-end will be the draft revision that existed at the moment the experiment status was set to 'live'. When displaying an alternative variation, the title and tree location are overridden to appear as the control page's title and location; this means that the title of the alternative page can be set to something descriptive, such as "Signup page (blue text)", without this text 'leaking' to site visitors.
43+
1544

1645
Direct URLs for goal completion
1746
-------------------------------
@@ -29,3 +58,48 @@ If you want goal completion to be linked to some action other than visiting a de
2958
3059
# ...
3160
]
61+
62+
63+
Alternative backends
64+
--------------------
65+
66+
wagtail-experiments supports pluggable backends for tracking participants and completions. The default backend, ``experiments.backends.db``, records these in a database table, aggregated by day. Alternative backends can be specified through the ``WAGTAIL_EXPERIMENTS_BACKEND`` setting:
67+
68+
.. code-block:: python
69+
70+
WAGTAIL_EXPERIMENTS_BACKEND = 'mypackage.backends.thecloud'
71+
72+
A backend is a Python module that provides the following functions:
73+
74+
**record_participant(experiment, user_id, variation, request):**
75+
76+
Called when a user visits the control page for ``experiment``. ``user_id`` is the persistent user ID assigned to that visitor; ``variation`` is the Page object for the variation to be served; and ``request`` is the user's current request.
77+
78+
**record_completion(experiment, user_id, variation, request):**
79+
80+
Called when a visitor completes the ``experiment``, either by visiting the goal page or triggering the ``record_completion``. ``user_id`` is the persistent user ID assigned to that visitor; ``variation`` is the Page object for the variation that was originally served to that user; and ``request`` is the user's current request.
81+
82+
**get_report(experiment):**
83+
84+
Returns report data for ``experiment``, consisting of a dict containing:
85+
86+
``variations``
87+
A list of records, one for each variation (including the control page). Each record is a dict containing:
88+
89+
``variation_pk``
90+
The primary key of the Page object
91+
92+
``is_control``
93+
A boolean indicating whether this is the control page
94+
95+
``is_winner``
96+
A boolean indicating whether this variation has been chosen as the winner
97+
98+
``total_participant_count``
99+
The number of visitors who have been assigned this variation
100+
101+
``total_completion_count``
102+
The number of visitors assigned this variation who have gone on to complete the experiment
103+
104+
``history``
105+
A list of dicts showing the breakdown of participants and completions over time; each dict contains ``date``, ``participant_count`` and ``completion_count``.

0 commit comments

Comments
 (0)