Skip to content

Instantly share code, notes, and snippets.

@lkraav
Last active March 11, 2016 12:15
Show Gist options
  • Save lkraav/58954601159ce0a28ea9 to your computer and use it in GitHub Desktop.
Save lkraav/58954601159ce0a28ea9 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._gaq = window._gaq || [];
window._gaq.push(['_trackEvent', 'Optimizely', experimentName, variationName, 0, true]);
// hotjar recordings tags
window.hj = window.hj || function() {(hj.q = hj.q || []).push(arguments)};
window.hj('tagRecording', [experimentName, variationName]);
}
})();
@lkraav
Copy link
Author

lkraav commented Feb 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment