Using Website Optimizer and Google Analytics together

Tracking scripts for Google Website Optimizer and Google Analytics work together easily. Just paste both the Website Optimizer and Analytics scripts in your head section.

Identifying your type of code


In order to check if you are using the code correctly, you'll need to figure out whether you're using Website Optimizer's asynchronous JavaScript tags (standard for experiments started after January 4, 2011) or the traditional ga.js code. The easiest way to do this is to look at the third line of your tracking or control script. If it starts with var gaJsHost, then you are using traditional ga.js code. If it starts with var _gaq, then you are using asynchronous tagging. If you are not using asynchonous tagging, you should generate a new set of scripts for your experiment by creating a new experiment with the same specifications.

Example of the scripts on your page


Paste your Website Optimizer script at the beginning of your <head> section. Then, paste your Analytics script immediately before your closing </head> tag.

Here's what the final code would look like on your conversion or variation page (the script for your original page would be different, but in the same location on your page):

<head> <!-- Google Website Optimizer Tracking Script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['gwo._setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['gwo._trackPageview', '/YYYYYYYYYY/ZZZZ']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End of Google Website Optimizer Tracking Script -->

… More contents in your header …

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-WWWWWWWW-W']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

</head>

In the above example, substitute your Google Analytics Account ID for UA-WWWWWWWW-W, your Google Website Optimizer Account ID for UA-XXXXXXXX-X, and your Website Optimizer experiment ID for YYYYYYYYYY. If you use the same account for Google Analytics and Website Optimizer, your Account IDs might be the same. Also, if you are adding a tracking script, you should replace ZZZZ with test, but if you are adding a conversion script, you should replace ZZZZ with goal.

 



Subscribe

Subscribe to our full RSS feeds

Network with us on LinkedIn

Visit with us on Facebook

Keep up to date on Twitter

Our blogs also on Wordpress

 

 

 

Contact Us

Selram is waiting for your Call!

You can contact us via our Enqiury Page. If you'd prefer to give us a ring you can always call us at: +91 96292 38961

Our Address

#4, TNHB, 2nd Avenue, Besant Nagar, Chennai, Tamilnadu, India

#3, Narayana Complex, Kadayanallur, Tenkasi TK, Tirunelveli DT, Tamilnadu, India

Loading...