Mobile app version of vmapp.org
Login or Join
Frith620

: Tracking multiple domains under subdomain I need to setup a Google Analytics code for one website with multiple domains, but they are in form of subdomain.**foo**.com subdomain.**bar**.com Subdomain

@Frith620

Posted in: #GoogleAnalytics

I need to setup a Google Analytics code for one website with multiple domains, but they are in form of

subdomain.**foo**.com
subdomain.**bar**.com


Subdomain is the same (it doesn't really matter that much), but main domains are differents. So now I use:

_gaq.push(['_setDomainName', 'subdomain.foo.com']);


and

_gaq.push(['_setDomainName', 'subdomain.bar.com']);


is this correct?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Frith620

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cooney921

On foo.com you use

_gaq.push(['_setDomainName', 'foo.com']);
_gaq.push(['_setAllowLinker', true]);


and on bar.com you use

_gaq.push(['_setDomainName', 'bar.com']);
_gaq.push(['_setAllowLinker', true]);


This includes Subdomains (whatever).foo.com and (whatever).bar.com.

If you want to link from ().foo.com to (.).bar.com or vice versa, between the different domains, then the _setAllowLinker set to true comes into play and you have to add additional code to your link (see the first tracking example in the mentioned documentation). You don't need this if you link, e.g., from a.foo.com to xyz.foo.com.

It's explained in the documentation:


A session from one domain can only be transferred to another domain via a properly configured click or form submission, or via _getLinkerURL.


The setDomainName:


This method sets the domain field of the cookie to the string provided in the parameter. With this method, you can control the domain name used by the cookie. You will ONLY have to set up linking between top-level domains because sub-domains will share the same cookies with their parents.

10% popularity Vote Up Vote Down


 

@Harper822

As per defined in the doc it seems to be the right method:


_setDomainName('yourDomainName')

What it does.
This method sets the domain field of the cookie to the string provided in the parameter. With this method, you can control the domain name used by the cookie. You will ONLY have to set up linking between top-level domains because sub-domains will share the same cookies with their parents.

When to use it.
Use this when you want to treat top- and sub-domains as one entity and track in the same profile. Also use this when you want to track across multiple top-level domains AND their sub-domains. In this case, you will need to using linking between the top-level domains, but not between the top-level domains and their sub-domains.

When not to use it.
If you are tracking a single domain, you do not need to explicitly set the domain name.


I also recommend you to read this part of the documentation: Tracking Multiple Domains - Web Tracking (ga.js).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme