Implementing A / B test tracking requires updating the Google Analytics script.
The operation consists of entering a custom variable with the value "yes" or "no" depending on whether the page is optimized or not.
Adding the custom variable
Here is the tag to add between _gaq.push(['_setAccount'
and_gaq.push(['trackPageViews']);
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
// Début du code à copier-coller
var cookie = document.cookie;
if (cookie.indexOf('fstrz=') !== -1) {
_gaq.push(['_setCustomVar', 5, 'Fasterize', cookie.indexOf('fstrz=true') !== -1 ? 'yes' : 'no', 2]);
} else {
_gaq.push(['_setCustomVar', 5, 'Fasterize', 'untracked', 2]);
}
_gaq.push(['_setSiteSpeedSampleRate', 100]);
// Fin du code à copier-coller
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article