Back in November 2008 Shawn Purtell at ROI Revolution posted some JavaScript code to integrate Google Website Optimizer data into Google Analytics. So I was testing it out in December, and it is extremly cool, but I had some picky issues with the JavaScript code that I want to mention.
This is ROI Revolution's provided code:
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “https://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E”));
]]>
And here is the script after some minor tweaks that I made:
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “https://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E”));
]]>
You will notice when comparing the two code blocks that the bottom block of code is creating a function which takes a string as input (used to identify the test in your GA reports), creates some temporary function scoped variables, and sends the obtained info to Google Analytics. In the top block of code, you cannot input a string to uniquly identify the test (you have to manually change it), and the variables used are global variables named 's' and 'l', which could possibly conflict with other global variables of the same name, which could potentially cause javascript errors on your site.
As consumers become increasingly digitally savvy, and more and more brand touchpoints take place online,…
Marketers are on a constant journey to optimize the efficiency of paid search advertising. In…
Unassigned traffic in Google Analytics 4 (GA4) can be frustrating for data analysts to deal…
This website uses cookies.