Thursday, March 25, 2010

Cookie Tracking in GA using _setVar function

Ever since I started using Google Analytics to track users on my blog, I have been itching to find a way to track each individual browser to my blog. I came to know that GA had the provision for IP tracking but this functionality was discontinued due to privacy issues arising out of it.


I only wanted a unique identifier to be associated with each individual who visited the blog. I recently found a way to do so. In one of my earlier blogs, I had described how the _setVar function can be used to exclude your own visits to your blog. Well it can be put to other good uses as well such as tracking each visitor to your site using the cookie id of the _utma cookie set by GA.

Since as long as the visitor doesnot remove the _utma cookie, it persists, as such he can be tracked using this id. What I have done is just extracted this cookie id value from the _utma cookie and put it in the _utmv cookie using the _setVar function . Put the following code in place of your simple google analytics code :

Code

So then when I go to the user defined table under Visitors, I can get these cookie ids and look at the visits , pageviews/visits and other metrics associated with the cookies.




This opens up avenues for lot of segmentation. For example you can identify the browsers that seem to be returning most of the times to your site. You can also segment the cookies based on geo location which can be pretty cool, because you can now understand where each individual visitor is coming from.

No comments:

Post a Comment

Feeds