Last active
August 29, 2015 14:17
-
-
Save doublejosh/59ec87a8fb1083c98661 to your computer and use it in GitHub Desktop.
AB test a new JS feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var should_show = $.cookie('testNameSpace'); | |
| // Allow A/B test override. | |
| if ($('body.override').length > 0) should_show = 1; | |
| // User is a yes OR no choice yet. | |
| if (should_show == 1 || (should_show == null && Math.random() < 0.2)) { | |
| //Set cookie to yes. | |
| $.cookie('testNameSpace', 1, { path : '/' }); | |
| thingToTest(); | |
| } | |
| else { | |
| // Hide form untested users. | |
| $.cookie('testNameSpace', 0, { path : '/' }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment