Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save robisatthefunction/525c93a795339e8a78da0ef3755784c1 to your computer and use it in GitHub Desktop.

Select an option

Save robisatthefunction/525c93a795339e8a78da0ef3755784c1 to your computer and use it in GitHub Desktop.
// [WARNING] You must disable 'Mask descriptive names in project code and third-party' in this project's settings for this to work! See here https://support.optimizely.com/hc/en-us/articles/4410284343181-Project-Settings-Privacy#01H84ETPDDFDXMTYDWWAX92EKG
var decisionObject = window.optimizely.get('state').getDecisionObject({
campaignId: campaignId,
shouldCleanString: true
});
var utils = window.optimizely.get('utils');
function sendToAnalyticsProvider() {
var experimentName = decisionObject.experiment.split(' ')[0];
var variationName = decisionObject.variation.split(' ')[0];
utils.waitUntil(function(){
return !!window.analyticsObject; // Change to analytics provider window object
}).then(function(){
// Send to analytics provider code
});
}
if ((!!decisionObject && decisionObject.holdback === undefined) || decisionObject.holdback === false) {
sendToAnalyticsProvider();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment