Skip to content

Instantly share code, notes, and snippets.

@lkraav
Last active March 11, 2016 12:13
Show Gist options
  • Save lkraav/2ac6f6aef6d3d0a2fb71 to your computer and use it in GitHub Desktop.
Save lkraav/2ac6f6aef6d3d0a2fb71 to your computer and use it in GitHub Desktop.
(function(){
// @version 2016.03.11
var experimentID = COPY_PASTE_ID_FROM_URL;
window.optimizely = window.optimizely || [];
// avoid firing in editor
if (window.optimizely.activeExperiments.indexOf(experimentID.toString()) == -1) return;
if (typeof window.optimizely.data.experiments[experimentID] !== 'undefined') {
var experimentName = experimentID + ' ' + window.optimizely.data.experiments[experimentID].name;
var variationName = window.optimizely.data.state.variationNamesMap[experimentID];
// google analytics events
window.ga = window.ga || function() {(window.ga.q = window.ga.q || []).push(arguments);}; window.ga.l =+ new Date();
window.ga('send', 'event', 'Optimizely', experimentName, variationName, {'nonInteraction': 1});
// hotjar recordings tags
window.hj = window.hj || function() {(hj.q = hj.q || []).push(arguments)};
window.hj('tagRecording', [experimentName, variationName]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment