{"id":16225500,"url":"https://github.com/mikebild/ab-test-example","last_synced_at":"2025-04-08T03:38:46.217Z","repository":{"id":31929175,"uuid":"35498635","full_name":"MikeBild/ab-test-example","owner":"MikeBild","description":"Simplified AB-Tests with MicroServices","archived":false,"fork":false,"pushed_at":"2015-06-03T16:02:59.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T02:47:26.923Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://mikebild.github.io/ab-test-example","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeBild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-12T16:08:55.000Z","updated_at":"2021-09-19T12:30:33.000Z","dependencies_parsed_at":"2022-08-25T07:51:13.048Z","dependency_job_id":null,"html_url":"https://github.com/MikeBild/ab-test-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeBild%2Fab-test-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeBild%2Fab-test-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeBild%2Fab-test-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeBild%2Fab-test-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeBild","download_url":"https://codeload.github.com/MikeBild/ab-test-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773741,"owners_count":20993632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T12:45:15.511Z","updated_at":"2025-04-08T03:38:46.192Z","avatar_url":"https://github.com/MikeBild.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simplified AB-Test Example\n\n\u003e \"Write programs that do one thing and do it well.\" — Doug McIlroy, Unix philosophy \n\nMake 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.\n\n* [Live AB-Test Example](http://mikebild.github.io/ab-test-example)\n* [Ad-Hoc-Statistics](https://demoabtest.subkit.io/api/AB-css-colored-button-stats)\n\n##Setup Example\n\n###Client\n\n```\nopen app/index.html\n```\n\n###Service\n\n```\ncd services\nsubkit update abtest\nsubkit start abtest\n```\n\n##How-To \nTesting different versions of text, backend rendered HTML templates, different backend APIs, layouts, images, or colors in the browser has never been more simple.\n\n### add variants\nRegister the a/b test variants. e.g.\n\n```\nAB.test(['red','green','blue'], 1);\n```\n\n### frequently you want to run the a/b tests\n* 1 will always run the a/b test\n* 0.5 will run the test 50% of the time\n* 0.2 will run the test two out of ten times\n* 0.001 will run the test one thousandth of the time\n\n### track `shown` and `chose`\n\n**Track impression**\n\n```\nAB.track({shown:cssClass});\n```\n\n**Track visit**\n\n```\nAB.track({chose:cssClass});\n```\n\n##Conversion rate statistics\nHow 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.\n\nAn ad-hoc Event-Log-Projection is used to analyse and calculate the conversion rates for different feature `css-colored-button` variants.\n\n[Ad-Hoc-Statistics](https://demoabtest.subkit.io/api/AB-css-colored-button-stats)\n\n````\ntask.eventsource  \n  .from(['AB-css-colored-button'])  \n  .run({\n    $init: function(){\n      return {\n        visit: {\n          count: 0\n        },\n        impression: {\n          count: 0\n        },\n        conversion: {}\n      };      \n    },\n    $any: function(state, e){\n      if(e.shown){\n        state.conversion[e.shown] = 0;\n        state.impression.count += 1;\n        if(!state.impression[e.shown]) state.impression[e.shown] = 0;\n        state.impression[e.shown] += 1;\n      }\n      \n      if(e.chose){\n        state.conversion[e.chose] = 0;\n        state.visit.count += 1;\n        if(!state.visit[e.chose]) state.visit[e.chose] = 0;\n        state.visit[e.chose] += 1;\n      }      \n\n      return state;\n    },\n    $completed: function(state){\n      for(var idx in state.conversion){\n        state.conversion[idx] = state.visit[idx] / state.impression[idx] * 100 || 0;\n      } \n      return state;\n    }\n  }, task.done);\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikebild%2Fab-test-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikebild%2Fab-test-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikebild%2Fab-test-example/lists"}