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

GA4 and BigQuery: why might data not match?

One of the most common questions we get about GA4 isn’t really about GA4, itself.…

2 weeks ago

GA4 + Optimizely: Integration Overview

Using engagement data to improve website performance is a near-universal use-case for users of Google…

2 months ago

Google Delays Third-Party Cookie Deprecation to 2025

Google announced on April 23 that it will again delay third-party cookie deprecation (3PCD) in…

3 months ago

This website uses cookies.