Sign in

Website Optimizer Help



Using Website Optimizer and Google Analytics together

Print

Tracking scripts for Google Website Optimizer and Google Analytics work together easily. Just paste the Website Optimizer script after the Analytics script. Here's what the final code will typically look like, with the Analytics script in blue and the Website Optimizer script in green:

<script type="text/javascript">
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"));
</script>
<script type="text/javascript">
try {

var pageTracker = _gat._getTracker("UA-xxxxx-x");
pageTracker._trackPageview();


} catch(err) {} </script>

<script type="text/javascript"> if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+ (document.location.protocol=='https:'?'s://ssl':'://www')+ '.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {

var gwoTracker=_gat._getTracker("UA-yyyyy-y");
gwoTracker._trackPageview("/zzzzzzzzzz/zzzz");
}catch(err){} </script>

Want more detailed instructions? Here's a step-by-step walkthrough of the process for adding Website Optimizer code to your existing Google Analytics code on experiment pages.

  1. Create a new experiment in Website Optimizer as normal. Follow the steps to choose an A/B or Multivariate experiment, name your experiment, and so on.
  2. When you get to step 2, where you are given the GWO tracking script code, copy and paste the whole tracking code into your experiment pages after the Analytics tracking code. The account number (UA-yyyyy-y) may be different from your Google Analytics account number (UA-xxxxx-x). This is normal and won't affect your experiment.
  3. That's it. Both Website Optimizer and Google Analytics are both set up on that page, and the pages can be tracked and analyzed by both.
For advanced experiments that track across subdomains, such as moving from store.example.com to checkout.example.com, you'll need to use different code. In that case, please see this article instead.

Was this information helpful?


Learn from other users

Ask questions, share answers, and post your favorite Website Optimizer tips and tricks on the Google Website Optimizer Help Forum.

Get help from our consultants

Check out our new Google Website Optimizer Service Plans.