You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This addon is paid software. You may use it for free during development, but you must purchase a license from the Statamic Marketplace before deploying to production.
6
+
3
7
## Installation
4
8
5
9
`composer require thoughtco/statamic-ab-tester`
6
10
11
+
then run
12
+
13
+
`php artisan migrate`
14
+
15
+
## Custom database connection
16
+
This addon uses your default database to store results, in a new table it creates called `ab_test_results`. If you want to specify a custom connection, use add the connection name to your .env:
17
+
18
+
`AB_TESTER_RESULTS_CONNECTION=your-connection`
19
+
7
20
## Usage
8
21
22
+
### Create a goal
23
+
One installed the first step is to create a goal through the UI. Name it whatever you want (for example "Mailing List Signup" or "Add to Basket") and give it a unique handle.
24
+
25
+
Now you want to trigger that handle in your code - to do that simply call:
If you need to trigger goals from Javascript, include the `{{ ab:js }}` in your layout, then call:
43
+
44
+
`abTester.hit('experiment-id', { custom: 'data' })` to register a hit on an experiment
45
+
46
+
`abTester.completed('goal-id', { custom: 'data' })` to register a goal success
47
+
48
+
`abTester.failed('goal-id', { custom: 'data' })` to register a goal failure
49
+
50
+
51
+
### Create an experiment
52
+
Next you need to make an experiment, which varies something on your site. To do this use the "Create A/B Experiment" action available on an entry.
53
+
54
+
This will open a window allowing you to choose what field(s) you want to vary and define their alternate values.
55
+
56
+
Finally, ensure you associate them with the goal you created in the first step.
57
+
58
+
59
+
### Outputting experiments
60
+
This add-on will automate the display of the variants, knowing when the item is augmented and switching it as appropriate.
61
+
62
+
If you are using full static caching, Statamic is never booted, so you will need to use `{{ nocache }}` alongside the tags this addon provides to run your experiments.
63
+
64
+
65
+
### Static caching
66
+
If you are using the `half` caching strategy, switch to using the provided `ab` driver - this extends half caching but allows ab experiments to continue working.
67
+
68
+
If you are using `full` static caching, you will need to wrap any experiments in `{{ nocache }}` tags and ensure you are using the tags to record hits, successes and failures.
69
+
70
+
71
+
### Field selection
72
+
By default all fields will be selectable to apply an A/B Test but you can control this using the `Allow this field to be A/B tested` config field that this add-on sets on each fieldtype.
73
+
74
+
If it makes sense for you to to default to fields not being included, you can set the `statamic-ab-tester.blueblueprint_fields_approach` to be 'opt-out'.
75
+
76
+
9
77
### Experiment types
10
78
There are two types of experiments you can run:
11
79
12
-
#### Entry
13
-
An Entry experiment lets you select an entry and display its content on the page. This can be selected from any collection and will be available as an `entry` variable inside the `ab` tag.
80
+
#### Item
81
+
An Item experiment lets you select an entry and modify its content from the base entry. These can be created using the `Create A/B Experiment` action on the entry view.
14
82
15
83
#### Manual
16
-
A Manual experiment lets you determine what you want to do inside the experiment, e.g. show a different nav UI, show a different button style. You can use the autogenerated `variant:id` or use `variant:label` to determine what to show to the user.
84
+
A Manual experiment lets you determine what you want to do inside the experiment, e.g. show a different nav UI, show a different button style. You can use the `variant:handle` to determine what to show to the user.
17
85
18
86
### Tags
19
87
This package provides tags that you can use in your Statamic templates:
@@ -24,68 +92,93 @@ This tag sets an A/B test for the given handle. It will randomly choose a experi
24
92
If you want your variant to persist over the session lifetime, set session="true"
25
93
26
94
```antlers
27
-
{{ ab experiment="experiment_handle" session="true" }}
28
-
{{ experiment}} {{ variant }}
95
+
{{ ab experiment="experiment_id" session="true" }}
0 commit comments