Tracking Custom Functionality via Custom Variables in Google Analytics
One of the biggest slights that I have heard recently about Google Analytics vs. a paid service (Omniture SiteCatalyst, Coremetrics, WebTrends), is that it can’t track custom variable and can only handle out of the box tracking through its ga.js file. However, this isn’t correct.Within Google Analytics, you are allotted 5 custom variables for which you can allocate any user behavior occurring on the site. Below is an example of how the variable is called within Google Analytics:pageTracker._setCustomVar(2, “Basketball”, “NBA D-League”, 2);Above, the first value, 2, signifies the variable that this will fall into. You can select 1-5 in this area. The “Basketball” is the top level name for the content category in this case Basketball. The 3rd value, “NBA D-League”, is the value that we want to assign to the Basketball category. The last value is the scope for the variable. There are three potential values that can go in here: 1 for visitor level, 2 for session level and 3 for page level.Now with the above variable, which needs to be placed above the trackPageview() function (as shown below):<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-0000000-1″);pageTracker._setCustomVar(2, “Basketball”, “NBA D-League”, 2);pageTracker._trackPageview();</script>Now track a host of things but remember that you only have 5 variables available for customization so choose wisely.
Written by:
Dorian D. Regester
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.


Today I began implementing Event Tracking for Google Analytics. Using the new Asynchronous methods, it took about 5 minutes to set up events for video usage on http://my.coreperformance.com. check out the new Asynchronous methods and event tracking!
There is a way to get more than 5 custom variables in Google Analytics, though it’s undocumented.Details here:http://analyticsimpact.com/2010/05/24/get-more-than-5-custom-variables-in-google-analytics/
This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!