Web Analytics

Minor Updates to the ROI Revolution Google Website Optimizer and Google Analytics Integration Script

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.

Author

cp_admin

Share
Published by
cp_admin

Recent Posts

Building a Scalable Analytics Program: When to Bring in DXA Tools like Contentsquare

Most analytics programs begin with foundational platforms like Google Analytics or Adobe Analytics. These tools…

1 week ago

Mastering GA Custom Metrics – Best Practices & Pitfalls to Avoid

In our previous post, we covered why custom metrics in GA matter and how to…

2 weeks ago

Unlocking User Behavior: The Power of Session Replay + AI Analytics

In today’s fast-paced digital world, marketing and product teams don’t just need data—they need answers,…

2 weeks ago

This website uses cookies.