Skip to content

Commit 06fdf29

Browse files
author
André Ekeberg
committed
Initial release
0 parents  commit 06fdf29

File tree

16 files changed

+3173
-0
lines changed

16 files changed

+3173
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# OS files
2+
.DS_Store
3+
Thumbs.db
4+
5+
# Composer
6+
vendor
7+
composer.lock

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [1.0.0] - 2020-04-29
6+
7+
Initial release
8+
9+
[1.0.0]: https://github.com/andreekeberg/abby/releases/tag/1.0.0

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 André Ekeberg
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# 🙋‍♀️ Abby
2+
3+
Abby is a simple but powerful A/B testing library.
4+
5+
The library lets you easily setup your **experiments** and their **control** and **variation** groups, **track** your visitors and assign them to a group, get detailed statistics including recommended **sample sizes** and determining the confidence of your results, including when an experiment have achieved **statistical significance**.
6+
7+
The confidence is calculated using the [z-score](https://en.wikipedia.org/wiki/Standard_score) and [p-value](https://en.wikipedia.org/wiki/P-value) of your results, to see if the [null hypothesis](http://en.wikipedia.org/wiki/Null_hypothesis) can be rejected. An accompanying minimum [sample size](https://en.wikipedia.org/wiki/Sample_size_determination) is also calculated using a [two-tailed test](https://en.wikipedia.org/wiki/One-_and_two-tailed_tests) to control the [false discovery rate](https://en.wikipedia.org/wiki/False_discovery_rate).
8+
9+
Abby is dependency free, and completely database agnostic, meaning it simply works with data you provide it with, and exposes a variety of methods for you to store the result in your own storage of choice.
10+
11+
## Requirements
12+
13+
- PHP 5.4.0 or higher
14+
15+
## Installation
16+
17+
```
18+
composer require andreekeberg/abby
19+
```
20+
21+
## Basic usage
22+
23+
### Tracking a user
24+
25+
```php
26+
// Setup a new Token instance
27+
$token = new Abby\Token();
28+
29+
// If we can't find an existing token cookie, generate one and set tracking cookie
30+
if (!$token->getValue()) {
31+
$token->generate()->setCookie();
32+
}
33+
34+
// Setup a User instance
35+
$user = new Abby\User();
36+
37+
// Associate the token with our user
38+
$user->setToken($token);
39+
```
40+
41+
### Adding existing user experiments to a user instance
42+
43+
```php
44+
// List of experiments associated with a tracking token
45+
$data = [
46+
[
47+
'id' => 1,
48+
'group' => 1,
49+
'converted' => false
50+
]
51+
];
52+
53+
// Loop through users existing experiments and add them to our user instance
54+
foreach ($data as $item) {
55+
// Setup experiment instance based on an existing experiment
56+
$experiment = new Abby\Experiment([
57+
'id' => $item['id']
58+
]);
59+
60+
// Setup a group instance based on stored data
61+
$group = new Abby\Group([
62+
'type' => $item['group']
63+
]);
64+
65+
// Add the experiment (including their group and whether they have
66+
// already converted) to our user instance
67+
$user->addExperiment($experiment, $group, $item['converted']);
68+
}
69+
```
70+
71+
### Including the using in new experiments
72+
```php
73+
// Experiment data
74+
$data = [
75+
'id' => 2
76+
];
77+
78+
// Make sure the experiment isn't already in the users list
79+
if (!$user->hasExperiment($data['id'])) {
80+
// Setup a new experiment instance
81+
$experiment = new Abby\Experiment([
82+
'id' => $data['id']
83+
]);
84+
85+
// Assign the user to either control or variation in the experiment
86+
$group = $user->assignGroup($experiment);
87+
88+
// Add the experiment (including assigned group) to our user instance
89+
$user->addExperiment($experiment, $group);
90+
}
91+
92+
// Getting updated user experiment list
93+
$user->getExperiments();
94+
95+
// Store updated experiment list for our user
96+
```
97+
98+
### Delivering a custom experience based on group participation
99+
100+
```php
101+
// Experiment data
102+
$data = [
103+
'id' => 1
104+
];
105+
106+
// If the user is part of the variation in our experiment
107+
if ($user->inVariation($data['id'])) {
108+
// Apply a custom class to an element, load a script, etc.
109+
}
110+
```
111+
112+
### Defining a user conversion in an experiment
113+
114+
```php
115+
// Experiment data
116+
$data = [
117+
'id' => 1
118+
];
119+
120+
// On a custom experiment goal, check if user is a participant and define a conversion
121+
if ($user->isParticipant($data['id'])) {
122+
$user->setConverted($data['id']);
123+
}
124+
125+
// Getting updated user experiment data
126+
$user->getExperiments();
127+
128+
// Store updated data for our user
129+
```
130+
131+
### Getting experiment results
132+
133+
```php
134+
// Setup experiment instance with stored results
135+
$experiment = new Abby\Experiment([
136+
'groups' => [
137+
[
138+
'name' => 'Control',
139+
'size' => 3000,
140+
'conversions' => 300
141+
],
142+
[
143+
'name' => 'Variation',
144+
'size' => 3000,
145+
'conversions' => 364
146+
]
147+
]
148+
]);
149+
150+
// Retrieve the results
151+
$result = $experiment->getResult();
152+
153+
// Get the winner
154+
$winner = $result->getWinner();
155+
156+
/**
157+
* Get whether we can be confident of the result (even if we haven't
158+
* reached the minimum group size for each variant)
159+
*/
160+
161+
$confident = $result->isConfident();
162+
163+
/**
164+
* Get the minimum sample size required for each group to reach statistical
165+
* significance, given the control groups current conversion rate (based on
166+
* the configured minimumDetectableEffect)
167+
*/
168+
169+
$minimum = $result->getMinimumGroupSize();
170+
171+
/**
172+
* Get whether the results are statistically significant
173+
*/
174+
175+
$significant = $result->isSignificant();
176+
177+
/**
178+
* Get complete experiment result
179+
*/
180+
181+
$summary = $result->getAll();
182+
```
183+
184+
## Documentation
185+
186+
* [Experiment](docs/Experiment.md)
187+
* [Token](docs/Token.md)
188+
* [User](docs/User.md)
189+
* [Group](docs/Group.md)
190+
* [Result](docs/Result.md)
191+
192+
## Changelog
193+
194+
Refer to the [changelog](CHANGELOG.md) for a full history of the project.
195+
196+
## License
197+
198+
Abby is licensed under the [MIT license](LICENSE).

composer.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "andreekeberg/abby",
3+
"type": "library",
4+
"description": "🙋‍♀️ Minimal A/B Testing Library",
5+
"keywords": [
6+
"ab test",
7+
"ab testing",
8+
"conficence",
9+
"conversion rate",
10+
"conversion ratio",
11+
"conversions",
12+
"false discovery rate",
13+
"p-value",
14+
"probability value",
15+
"probability",
16+
"ratio",
17+
"sample size",
18+
"sample",
19+
"sequential testing",
20+
"significance",
21+
"split test",
22+
"split testing",
23+
"split-run",
24+
"standard score",
25+
"statistics",
26+
"testing",
27+
"two-sample",
28+
"two-tailed",
29+
"two-tailed test",
30+
"z-score"
31+
],
32+
"homepage": "https://github.com/andreekeberg/abby",
33+
"license": "MIT",
34+
"authors": [
35+
{
36+
"name": "André Ekeberg",
37+
"email": "andre@pocketsize.se",
38+
"homepage": "https://github.com/andreekeberg",
39+
"role": "Developer"
40+
}
41+
],
42+
"autoload": {
43+
"psr-4": {
44+
"Abby\\": "src/"
45+
}
46+
},
47+
"require": {
48+
"php": ">=5.4.0"
49+
}
50+
}

0 commit comments

Comments
 (0)