: Google Analytics Subdomain Tracking for WordPress I'm looking for the best solution to track my website's traffic using Google Analytics. I have a website that (currently) has two subdomains. The
I'm looking for the best solution to track my website's traffic using Google Analytics. I have a website that (currently) has two subdomains. The subdomains are about very different content, the TLD shows some basic information about me and also shows excerpts from the two underlying subdomains. I'd like to be able to see information for the whole site, but also be able to specify per subdomain.
Obviously I'd like to use the more recent Asynchronous Google Analytics script.
I couldn't find any decent and more importantly, recent solutions or implementations for this. Any tips or pointers would be appreciated.
More posts by @Voss4911412
2 Comments
Sorted by latest first Latest Oldest Best
I use this to track subdomains. Put this code at the end of your template before the </body> tag.
<script type="text/javascript">
//Tracking code customizations only
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'your analytics acct #']);
_gaq.push(['_setDomainName', '.your_domain_here.com']);
_gaq.push(['_setAllowHash', false]);
_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>
The you'll need to setup multiple filters in the analytics interface to see the data combined and separate.
EDIT to add filtering information :
Easy tutorial for setting up subdomain filters
I think this article describes what you want www.google.com/support/analytics/bin/answer.py?answer=55524. It does say it's for the old version of the script, but the same principles - using cross domain tracking, and filter to get the subdomain stats - should apply.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.