SEO24 - SEO news and opinion

Google Analytics - tracking multiple sub-domains in one account

Search Engine Marketing > VKI Studios Blog

Installing Google Analytics on a site that uses multiple sub-domains requires some custom configuration to the tracking code.For example, if you are installing GA on a site that has the following structure:Main site: www.mydomain.com
Store: store.mydomain.com
Blog: blog.mydomain.comIf you install the default code that Google provides, you will not get accurate metrics, especially in regards to visits and visitors. This is because, by default Google sets a first party cookie that is specifically for the domain that you're on.The above site uses sub-domains for different areas of the site, so every time someone moves from www.mydomain.com to store.mydomain.com a new cookie will be set and the user will be counted as a new visitor.Google has a way around this, you just need to tell it to set the cookie on the root domain. In this case: mydomain.comFor example, the default code that Google provides is something like the following.If you are using urchin.js, the default code is as follows:If you are using ga.js, the default code is as follows:To allow this code to track a single user across sub-domains in a single Google Analytics profile, you need to add an entry to specify the root domain.For urchin.js, you'll update the code to something similar to below. See the addition of the _udn variable where the domain is being set.For the ga.js code, your code would look like the following. See the addition of the pageTracker._setDomainName() function:In another post, we'll talk about how to track users between different domains.

Full article at: http://feeds.feedburner.com/~r/seo-and-usability/~3/232740340/Google-Analytics--tracking-multiple-subdomains-in-one-account


Other Channel Data

Channel Title: VKI Studios Blog
Channel Description: VKI Studios Blog - Professional Internet marketing and Website Usability Studies. More traffic, higher conversation rates, call VKI Studios today (866) 733-8899.
Channel Link: http://blog.vkistudios.com/index.cfm
Time added to seo24 archive: 13:20:11 - 11/02/2008 - Current server time: 10:39:11
seo24 Category: Search Engine Marketing

Other articles in this channel include:
Other articles in this category include: