Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikebild/ab-test-example
Simplified AB-Tests with MicroServices
https://github.com/mikebild/ab-test-example
Last synced: 9 days ago
JSON representation
Simplified AB-Tests with MicroServices
- Host: GitHub
- URL: https://github.com/mikebild/ab-test-example
- Owner: MikeBild
- Created: 2015-05-12T16:08:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-03T16:02:59.000Z (over 9 years ago)
- Last Synced: 2024-10-11T12:45:09.735Z (about 1 month ago)
- Language: JavaScript
- Homepage: http://mikebild.github.io/ab-test-example
- Size: 137 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simplified AB-Test Example
> "Write programs that do one thing and do it well." — Doug McIlroy, Unix philosophy
Make user-driven decisions with a simplified A/B test system. The client side is self contained without external dependencies. The client uses cryptographically random A/B test variant and track the results to a microservice backend.
* [Live AB-Test Example](http://mikebild.github.io/ab-test-example)
* [Ad-Hoc-Statistics](https://demoabtest.subkit.io/api/AB-css-colored-button-stats)##Setup Example
###Client
```
open app/index.html
```###Service
```
cd services
subkit update abtest
subkit start abtest
```##How-To
Testing different versions of text, backend rendered HTML templates, different backend APIs, layouts, images, or colors in the browser has never been more simple.### add variants
Register the a/b test variants. e.g.```
AB.test(['red','green','blue'], 1);
```### frequently you want to run the a/b tests
* 1 will always run the a/b test
* 0.5 will run the test 50% of the time
* 0.2 will run the test two out of ten times
* 0.001 will run the test one thousandth of the time### track `shown` and `chose`
**Track impression**
```
AB.track({shown:cssClass});
```**Track visit**
```
AB.track({chose:cssClass});
```##Conversion rate statistics
How you analyze the actionable data is up to you. In this simplified example the client uses one microservice for a AB-Test created with [Subkit](http://subkit.io) to track the impressions and visits for different feature variants.An ad-hoc Event-Log-Projection is used to analyse and calculate the conversion rates for different feature `css-colored-button` variants.
[Ad-Hoc-Statistics](https://demoabtest.subkit.io/api/AB-css-colored-button-stats)
````
task.eventsource
.from(['AB-css-colored-button'])
.run({
$init: function(){
return {
visit: {
count: 0
},
impression: {
count: 0
},
conversion: {}
};
},
$any: function(state, e){
if(e.shown){
state.conversion[e.shown] = 0;
state.impression.count += 1;
if(!state.impression[e.shown]) state.impression[e.shown] = 0;
state.impression[e.shown] += 1;
}
if(e.chose){
state.conversion[e.chose] = 0;
state.visit.count += 1;
if(!state.visit[e.chose]) state.visit[e.chose] = 0;
state.visit[e.chose] += 1;
}return state;
},
$completed: function(state){
for(var idx in state.conversion){
state.conversion[idx] = state.visit[idx] / state.impression[idx] * 100 || 0;
}
return state;
}
}, task.done);
```