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 using Google Analytics « Sam Enriquez
Sam Enriquez
SEM SEO and Web Analytics
Media Tech Creative Interactive Strategy Sam Greg
Sep
25
2009
Linking Domains and sub-domains using Google Analytics
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.

Tags: , , , , ,

You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

18 Responses to “Linking Domains and sub-domains using Google Analytics”

  1. 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.

    :)

  2. Very outstanding website.
    The information here is really important.

    I will refer it to my friends.

    Cheers

  3. Very good concept, I like how you convey the message.

  4. Such a great site. I am bookmarking this page.

  5. MrBlogg says:

    Great post..Keep them coming :) Thanks for sharing.

  6. I somehow dont agree with a few things, but its great anyways.

  7. padnqf says:

    vUAU4t zapepjfrearr, [url=http://dgtvmgodewum.com/]dgtvmgodewum[/url], [link=http://htouskcvzcea.com/]htouskcvzcea[/link], http://xfynnkmwkous.com/

  8. Good ideas there. Congrats on getting linked from ProBlogger! Keep up the good work.

  9. henk-jan says:

    I love your post thanks man

  10. Thank you concerning the wonderful information.

  11. cypeprurard says:

    The information here is great. I will invite my friends here.

    Thanks

  12. Thanks for the nice post. I always like to bookmark forex or financially related posts like this one.

  13. Private says:

    Hi I was just poking around the internet, looking for some knowledgable sites to read and bumped into your site.

  14. Ian Mitch says:

    It is always great to read good quality material like this.

  15. 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.

  16. to domain name says:

    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…

  17. SHOP ELECTRONICS!!! says:

    **YOUTUBE VIDEO REVIEWS ON THE HOTTEST ELECTRONICS OUT**…

    #1 SITE FOR THE LATEST REVIEWS ON THE HOTTEST TECHNOLOGY HITTING THE MAINSTREAM!…

  18. 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 :)…

Leave a Reply

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)