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.

Cardinal Path

Share
Published by
Cardinal Path

Recent Posts

Understanding Reporting Identity in Google Analytics 4

A fundamental question underpinning even the most basic reports in Google Analytics 4 (GA4) is…

1 week ago

Understanding the Path Explorer Report in GA4

Google Analytics 4 (GA4) has introduced several customizable reports through its Exploration feature, one of…

2 weeks ago

Merkle | Cardinal Path: Your Go-To Resource for Digital Analytics Expertise

Businesses of all sizes are constantly having to navigate through mountains of data to make…

3 weeks ago

This website uses cookies.