Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save simondahla/bc44a6ccba17d369141847b3a3c635dd to your computer and use it in GitHub Desktop.
Save simondahla/bc44a6ccba17d369141847b3a3c635dd to your computer and use it in GitHub Desktop.
function() {
if (window.optimizely) {
var o = optimizely;
if (o.activeExperiments && o.allExperiments) {
for (var i = 0; i < o.activeExperiments.length; i++) {
var experimentId = o.activeExperiments[i];
var experiment = o.allExperiments[experimentId];
if (experiment && experiment.universal_analytics) {
var slot = experiment.universal_analytics.slot;
if (slot == 3) { // you would fill this in with the slot you are using in Optimizely for this experiment.
if (o.variationIdsMap && o.variationNamesMap) {
return experimentId + ': ' + o.variationNamesMap[experimentId];
}
}
}
}
}
}
return undefined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment