Skip to content

Instantly share code, notes, and snippets.

@robisatthefunction
Created March 9, 2021 03:25
Show Gist options
  • Select an option

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

Select an option

Save robisatthefunction/b50447587d616d357d72d66c15d1379c to your computer and use it in GitHub Desktop.
/* This snippet runs everytime a "campaign decision" is made. */
var decisionObject = window.optimizely.get('state').getDecisionObject({
campaignId: campaignId,
shouldCleanString: true
});
//Check to see if a decision has been made. This will be null if the user is part of the holdback group
if (decisionObject) {
var experimentId = decisionObject.experiment.split(' ')[1].replace(/[()]/g, '');
var variationId = decisionObject.variation.split(' ')[1].replace(/[()]/g, '');
try {
_pxam.push({
type: 'event',
eventType: 'change',
eventSource: 'field',
feature: 'Optimizely Campaign',
label: experimentId + ‘ > ‘ + variationId
});
}
catch(e) {
}
/*//Back up Optimizely event to see if things work
window.optimizely.push({
"type": "event",
"eventName": "integrationSuccess"
});*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment