Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/rd/blogs/wp-settings.php on line 629

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/rd/blogs/wp-settings.php on line 644

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/rd/blogs/wp-settings.php on line 651

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/html/rd/blogs/wp-settings.php on line 687

Deprecated: Function set_magic_quotes_runtime() is deprecated in /var/www/html/rd/blogs/wp-settings.php on line 18
Linking Domains and sub-domains « Sam Enriquez
Sam Enriquez
SEM SEO and Web Analytics
Media Tech Creative Interactive Strategy Sam Greg

Posts Tagged ‘Linking Domains and sub-domains’

Sep
25
2009
by
sam

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.

image
Sam Enriquez
Associate
I'm an associate at Resolute Digital LLC with a speciality in Google Analytics and Website Optimizer. I've earned the Google Analytics "IQ" certification and work with Resolute clients to use Google Analytics to make better business decisions. In my spare time, I'm earning an economics degree of Chico State in California.
  • Archives
  • Categories
  • image
    Copyright © 2005-09 Resolute Digital LLC Digital Marketing Agency
    Entries (RSS) & Comments (RSS)