Created
September 15, 2016 21:17
-
-
Save abhiyerra/e24637d3ede79fcda2307311e9ad58db to your computer and use it in GitHub Desktop.
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 experiments = { | |
| "YvvWWQlbSLSUqKvi6YD": [ | |
| function() {}, | |
| function() { | |
| $("#support-nav").html("Support"); | |
| } | |
| ], | |
| "CeK01Si7S_m_c7iYjyu9Nw": [ | |
| function() {}, | |
| function() { | |
| $("h1").addClass("new-header-font"); | |
| } | |
| ] | |
| }; | |
| function getExperiment() { | |
| var acksinExp = localStorage.getItem("acksinExperiments"); | |
| // Get a new experiment | |
| if(acksinExp == null) { | |
| var expKeys = Object.keys(experiments); | |
| acksinExp = expKeys[Math.floor(Math.random() * expKeys.length)]; | |
| localStorage.setItem("acksinExperiments", acksinExp); | |
| return acksinExp; | |
| } | |
| // Check if experiment is still running, if it is get it. | |
| if(acksinExp in experiments) { | |
| return acksinExp; | |
| } | |
| // Remove the existing experiment and recurse so we can get the new experiment. | |
| localStorage.removeItem("acksinExperiments"); | |
| return getExperiment(); | |
| } | |
| $.getScript("//www.google-analytics.com/cx/api.js?experiment=" + getExperiment(), function(){ | |
| chosenVariation = cxApi.chooseVariation(); | |
| experiments[getExperiment()][chosenVariation](); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment