Created
January 5, 2016 23:09
-
-
Save aroach/da9215e3fd25bbfdc791 to your computer and use it in GitHub Desktop.
angular-optimizely
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
angular.module('myApp') | |
.service('ABTestService', function () { | |
this.abtestActivateExperiment = function(experimentId) { | |
console.log(experimentId); | |
window['optimizely'] = window['optimizely'] || []; | |
window.optimizely.push(["activate", experimentId]); | |
console.log(window['optimizely'].variations); | |
var variation = window.optimizely.variationMap; | |
// If variation exists return it, otherwise return default of 0 | |
return (typeof variation === 'undefined' ? 0 : variation); | |
}; | |
this.abtestEvent = function(event_name, event_properties) { | |
event_properties = typeof event_properties !== 'undefined' ? event_properties : {}; | |
window['optimizely'] = window['optimizely'] || []; | |
window.optimizely.push(["trackEvent", event_name, event_properties]); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment