Asynchronous Tracking Migration Part- II

Asynchronous Tracking Migration Part- II

  •  
  •  
  •  
  •   
  •  

In our previous post,[Asynchronous Tracking Code Migration from ga.js.] we discussed why Asynchronous tracking code is important and what are the methods to execute the migration process We are going to discuss some more of such methods in this post. Recently Google has announced that it will consider the site speed as a factor for the SERP in their official Analytics blog [ http://analytics.blogspot.com/2010/04/making-web-faster.html ], so how about considering Asynchronous tracking code to increase the site speed?

Cross Domain Tracking
In this post we will discuss deeply on cross domain tracking migration for the following conditions:

  • How to track a single sub directory
  • How to track two subdirectories on a same domain
  • How to track a domain and subdirectory of another domain
  • How to track a domain and sub domains


How to track a single sub directory

If you create a blog for your website as a folder like http://www.yourwebsite.com/blog Now you want to see the stats of this folder alone on analytics then you need to use _setCookiePath() method. Here is the migration guide for this

Traditional ga.js Medhod
var pageTracker = _gat._getTracker(“UA-12345-1”);
pageTracker._setCookiePath(“/blog/”);
pageTracker._trackPageview();

Asynchronous Method:
_gaq.push([‘_setAccount’, ‘UA-12345-1’]);
_gaq.push([‘_setCookiePath’, ‘/blog/’]);
_gaq.push([‘_trackPageview’]);

While you use the _setCookiePath() then you need to consider the following points.

  • Your visitor statistics like new vs returning, time on site and number of visits might be incorrect because of your cookie might reflect in other parts of your website
  • Your reports might reflect campaign details from another store

How to track two subdirectories on a same domain:
If you want to track two subdirectories in your site then you need to use one more method for the second subdirectory viz _cookiePathCopy(). For example, if you want to track your blog and event subdirecories then you need to place _setCookiePath() and _cookiePathCopy().

Traditional ga.js Method:
var pageTracker = _gat._getTracker(“UA-12345-1”);
pageTracker._setCookiePath(“/blog/”);
pageTracker._cookiePathCopy(“/event/”);
pageTracker._trackPageview();

Asynchronous Tracking Method:
_gaq.push([‘_setAccount’, ‘UA-12345-1’]);
_gaq.push([‘_setCookiePath’, ‘/blog/’]);
_gaq.push([‘_cookiePathCopy’, ‘/event/’]);
_gaq.push([‘_trackPageview’]);

How to track a domain and subdirectory of another domain
One more criteria is tracking a full domain and a subdirectory of another domain. This will happen when you have an online store but you can use a 3rd-party website for your shopping cart, where you have limited access to a sub-directory of that site. You need to place two codes for your online store and the subdirectory of the 3rd-party website. For example, if your primary site is http://www.example.com and the subdirectory of another domain is http://www.example-site.com/shopping-cart then, you need to place the below code:

Primary: http://www.example.com/
Traditional ga.js Tracking:

var pageTracker = _gat._getTracker(“UA-12345-1”);
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false)

Asynchronous Tracking Method:
_gaq.push([‘_setAccount’, ‘UA-12345-1’]);
_gaq.push([‘_setAllowLinker’, true]);
_gaq.push([‘_setAllowHash’, false]);

Subdirectory of another domain: http://www.example-site.com/shopping-cart
Traditional ga.js Tracking:
var pageTracker = _gat._getTracker(“UA-12345-1”);
pageTracker._setDomainName(‘none’);
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);

Asynchronous Tracking Method:
_gaq.push([‘_setAccount’, ‘UA-12345-1’]);
_gaq.push([‘_setDomainName’, ‘none’]);
_gaq.push([‘_setAllowLinker’, true]);
_gaq.push([‘_setAllowHash’, false]);

Whereas we need to pass the cookie values from the primary domain to the subdirectory of another domain using the following methods _linkByPost() and _link(). Using onsubmit() event we can pass our datas to the 3rd-party subdirectory shopping cart.

Traditional ga.js Tracking:
<form name=”f” method=”post” onsubmit=”pageTracker._linkByPost(this);”>

Asynchronous Tracking:
<form name=”f” method=”post” onsubmit=”_gaq.push([‘_linkByPost’, this]);”>

How to track a domain and sub domains:
If we want to track the subdomains of a website then we have useed the method called _setDomainName() to separate the vistitor data.
Suppose we take the following as our example

  • http://www.example.com
  • http://www.blog.example.com
  • http://www.event.example.com

Traditional ga.js Tracking:
var pageTracker = _gat._getTracker(“UA-12345-1”); pageTracker._setDomainName(“.example.com”);
pageTracker._trackPageview();

Asynchronous Tracking:
_gaq.push([‘_setAccount’, ‘UA-12345-1’]);
_gaq.push([‘_setDomainName’, ‘.example.com’]);
_gaq.push([‘_trackPageview’]);

Use the migration guide and change your traditional tracking code into Asynchronous tracking code to increase the site speed and get better tracking data.

, , ,

Open chat
1
Chat with our Experts!
Hello
Can I help you?