You are here: Home // miscellaneous // Google analytics: Tracking conversions across subdomains

Google analytics: Tracking conversions across subdomains

We’ve recently had to break something of a sweat in figuring out how to track conversions using Google analytics, when the goal funnel involves sub-domains.

In case anyone else runs into similar problems, here’s what you do:

1) Add this line(in BOLD, below) to your Google Analytics code, on both the starting page(step 1) as well as the conversion page(step 2).

<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-xxxxxx-x");
pageTracker._setDomainName(".example.com");
pageTracker._trackPageview();
} catch(err) {}
</script>

2. Then, if your start page(where visitors land) is: http://mydomain.com/start/index.php and your conversion page(where people land after signup or something like that) is: http://sub.mydomain.com/welcome/index.php, then you specify your funnel as:

Step 1: www.mydomain.com/start/index.php

Step 2: sub.mydomain.com/welcome/index.php

3.  That’s it. You’re done.

Tags: , , ,

blog comments powered by Disqus
unlimited hosting  
Copyright © 2009 marcellus. All rights reserved.
.