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.” : “http://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.” : “http://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

Google Delays Third-Party Cookie Deprecation to 2025

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

1 week ago

Understanding Funnel Reports in GA4

Funnel reports have long been one of the most actionable reports in a marketing analyst’s…

1 week ago

GA4 Monetization Reports: An Overview

GA4’s Monetization reports provide organizations with simple but actionable views into the revenue-generating aspects of…

2 weeks ago

This website uses cookies.