Search Engine Optimization Pay Per Click - PPC Campaign Management Affiliate Marketing Web Analytics Social Media Optimization - Blog Marketing
SERVICES
Search Engine Optimization Pay Per Click
Affiliate Marketing
Social Media Optimization
PR Optimization
Web Analytics

CORPORATE
About Us
The Team
News
Outsource to Us
Partnerships
Jobs at Convonix
RESOURCES
Articles
WhitePapers
Applications & Tools
SEO Blog
Case Studies
SEO Help - Ask Our Experts
CONTACT
Contact Us
Get a Free Quote
.
SEO articles

SEO Articles at Convonix

Articles from the Convonix team

Google Analytics Code – Code to Track Multiple Domains, Sub Domains & Third Party Shopping Carts

In our last article we explored the basic Google Analytics code. In this article we’ll talk about the variation of the basic code to track sites which span across multiple domains or sub-domains. We’ll also look at the code used to track sites which use third party shopping carts.

Multiple Domains

If your site spans across multiple domains for example www.abc.com & www.def.com or you have a shopping cart integrated to your site which directs the user to separate domain then you need to use the following variation of the code on all pages of your site.

<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”>
try{
var pageTracker = _gat._getTracker(”UA-xxxxxx-x”);

pageTracker._setDomainName(”none”);

pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}

The pageTracker._setDomainName(”none”); sets the domain name for cookies. Setting the parameter to “None” makes sure that the cookies are not restricted to a particular domain.

The pageTracker._setAllowLinker(true); sets the linker functionality flag as part of enabling cross-domain user tracking and is used in conjunction with _link()function

In the second part of this code you’ll need to add the _link ( ) function to any links between the domains. Please note that your analytics tracking code and calls to _gat._getTracker (shown in Step 1) must be placed on the page above the call to _link. Say, for example your current link which directs the user to the third party shopping cart looks like:

<a href=”https://www.secondsite.com/?login=parameters”> Buy Now</a>

change them to:

<a href=”https://www.secondsite.com/?login=parameters” onclick=”pageTracker._link(this.href); return false;”>Buy Now</a>

The _link () function makes sure that the cookies are transferred between the two domains
If you send information between domains using forms, you’ll need to use the _linkByPost function. Your analytics tracking code and calls to _gat._getTracker (shown in Step 1) must be placed on the page above the call to _linkByPost.

<form action=”http://newdomain.com/form.cgi” onSubmit=”javascript:pageTracker._linkByPost(this)”>
This will work even for forms where the method=”GET”

Sub Domains

If you want to track traffic from various sub-domains or you have a third party shopping cart which directs the user to a sub-domain you just need to add pageTracker._setDomainName function to your basic analytics code as given below to all pages of your site as well as the sub-domains.

<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-xxxxxx-x”);
pageTracker._setDomainName(”.abc.com”);
pageTracker._trackPageview();
</script>

Setting the parameter of the pageTracker._setDomainName()function to “.abc.com” in the above code will help you to track traffic from various sub domains related to abc.com like help.abc.com, search.abc.com etc.

In our next article we’ll explore the code to track ecommerce transactions.

At Convonix, we understand the importance of web analytics in determining the effectiveness of an online property to achieve its goals. Convonix was the first Company to provide dedicated SEO in India, and has an expertise in handling complicated SEO Web Analytics setups.

The above article is Copyright of Convonix, Inc. This article may be copied for electronic publication on a blog, newsletter, or website, provided it is re-published in its original form, with the author information, copyright, and hyperlinks intact.

SEO | Corporate Profile | Outsource SEO | SEO Blog | SEO Articles | Research | SEO Tools | Careers |
Search Engine Marketing | Search Engine Optimization | Pay Per Click | Geo Specific Website Optimization: SEO India | SEO UK | Web
Analytics
| Social Media Optimization | Blog Marketing |
Useful Resources | Site Map | Privacy Policy
Copyright© 2004 Convonix™ Inc. - The Search Engine Optimization Firm (The SEO Firm in India). All rights reserved.