Some websites may benefit from having linked domains and/or sub-domains whether they are both owned by a parent company, are partners, or are related in some way and can provide interconnected data in order to send cookie information from one site to another. This can aid with identifying a websites source of referral traffic and act as a funnel in which visitors can be more accurately identified as either unique or recurring. Google Analytics uses 1st Party cookies thus using certain arguments to link cookie information between domains is useful and worthwhile process.
Firstly, access to your web server is needed and implanting of the Google Analytics tracking code is required on all pages of both domains. Example is as shown:
<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-7799676-1″);
pageTracker._trackPageview();
</script>
Now, before the </script> and trackPageview() ,
Insert the _setDomainName(”None”) _setAllowLinker(true); arguments into your code.
It should look like:
<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-7799676-1″);
pageTracker._setDomainName(”None”);
pageTracker._setAllowLinker(”true”);
pageTracker._trackPageview();
</script>
After the code highlighted in bold is inserted, call the _link() method to all links in between domains.
We will use an example linking Yourwebsite.com with yourotherwebsite.com by allowing cookie information to be shared using the link method. The following code using an example website:
On www.yourwebsite.com:
<a href= http://yourwebsite.com
Onclick=”pageTracker._link(’http://www.yourwebsite.com’);return false;”>Go to our sister site Yourotherwebsite.com</a>
Likewise, on www.yourotherwebsite.com use this code:
<a href= http://yourotherwebsite.com
Onclick=”pageTracker._link(’http://www.yourotherwebsite.com’);return false;”>Go to our sister site yourwebsite.com</a>
The link method allows for cookie information to transfer between different domains when the user clicks on the link to transfer to a different domain. The visitor’s session information will be preserved through first party cookies. Unfortunately, the link method does not work through means other than clicking on a link. If session information is wished to be preserved through other means, like a form, the _linkByPost() method must be used. An example would be:
<form action=http://www.exampleshoppingcart.com/service/formprocessor.php
Name=”f” method= “post” onsubmit=”pageTracker._linkbyPost(this)”>
(Other Misc. Content here…)
</form>
Tracking across multiple Subdomains is very useful for domains that are a part of larger domains if you would like tracking to span across different webpages organized into different departments, groups, etc. For example if your website is organized so that the shopping cart is directed to the url: cart.yourwebsite.com from yourwebsite.com, then in order to transfer cookie information between the parent domain and the sub-domain, the following steps must be followed:
First the standard ga.js tracking code must be implemented on the main web server for the code on that page of course, although a new line of code must be inserted after the var pageTracker argument is called which is the _setDomainName method. The following is what the code should look like. The highlighted text represents the argument that will preserve cookie information when a user is transferred from your parent domain to your sub-domain. This code will allow GA to track the visitor and identify that visitor as a referred visitor.
Google Tracking code inserted here…
</script>
Var pageTracker=_gat._getTracker(”Insert UA ID # here”);
pageTracker._setDomainName(”.yourmaindomain.com”);
pageTracker._trackPageview();
</script>
Again, once the parent domain is referenced, GA will share 1st party cookie information and transfer them from domain to sub-domain. In addition to linking domains with sub-domains Google Analytics also allows users to track across multiple domains with sub-domains.
In order to do this, additional code is required to set up on each sub-domain and primary domain. In order to do this you must call the _setAllowHash argument which will allow for cookie session information to be exchanged between multiple domains with sub-domains.
(Google Analytics tracking code must be inserted here)
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-7799676-1″);
pageTracker._setDomainName(”None”);
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPageview();
</script>
After this code is inserted on the host server for all the domains and sub-domains that you wish to be linked, the _link() or _linkbyPost() method can be used to track all links and/or forms between each domain. Note that these methods are not needed for all links or forms between sub-domains of the same domain only sub-domains of different domains.
On www.yourwebsite.com:
<a href= http://yourwebsite.com
Onclick=”pageTracker._link(’http://www.yourwebsite.com’);return false;”>Go to our sister site Yourotherwebsite.com</a>
Likewise, on www.yourotherwebsite.com use this code:
<a href= http://yourotherwebsite.com
Onclick=”pageTracker._link(’http://www.yourotherwebsite.com’);return false;”>Go to our sister site yourwebsite.com</a>
Again plant this code on all links/forms between your different domains as before except between sub-domains on the same domain.
Tags: Google Analytics, Linking Domains and sub-domains, Linking domains using Google analytics, PageTracker, Sam Enriquez, Web Analytics
You can follow any responses to this entry through the RSS 2.0 feed.

I like this web very much.
This is really a outstanding place.
And it is not like other money oriented place, the message here is super useful.
I am definitely bookmarking it as well as sharing it with my friends.
Very outstanding website.
The information here is really important.
I will refer it to my friends.
Cheers
Very good concept, I like how you convey the message.
Such a great site. I am bookmarking this page.
Great post..Keep them coming
Thanks for sharing.
I somehow dont agree with a few things, but its great anyways.
vUAU4t zapepjfrearr, [url=http://dgtvmgodewum.com/]dgtvmgodewum[/url], [link=http://htouskcvzcea.com/]htouskcvzcea[/link], http://xfynnkmwkous.com/
Good ideas there. Congrats on getting linked from ProBlogger! Keep up the good work.
I love your post thanks man
Thank you concerning the wonderful information.
The information here is great. I will invite my friends here.
Thanks
Thanks for the nice post. I always like to bookmark forex or financially related posts like this one.
Hi I was just poking around the internet, looking for some knowledgable sites to read and bumped into your site.
It is always great to read good quality material like this.
Hi i am so pleased I found your blog, I really found you by mistake, while I was searching Yahoo for something else, At Any Rate I am here now and would just like to say thank you for a wonderful blog posting and a all round intriguing blog (I also love the theme/design), I do not have time to read it all at the right now but I have bookmarked it and also added your RSS feeds.
hi guys…
hi guysI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well and i have start my own blog now, , thanks for your effort…
**YOUTUBE VIDEO REVIEWS ON THE HOTTEST ELECTRONICS OUT**…
#1 SITE FOR THE LATEST REVIEWS ON THE HOTTEST TECHNOLOGY HITTING THE MAINSTREAM!…
Very nice!…
Wow you are very very talented!! keep up the awesome work. You are very talented & I only wish I could write as good as you do :)…