Google Analytics Cross Domain Tracking

By Paulus, 17 February, 2009

If you control multiple domains and/or have multiple alias' then in order to track visitors across them, you must modify the Google Analytics tracking code:

<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">
var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script>

By adding what is bold will allow you to track across multiple domains.