Visitor click recording with Google Analytics
Visitor click recording is very effective way of knowing behavior of visitors. Its results can help improve site navigation and flow.
In this post I will discuss two methods to record clicks. The two methods are
- Event Tracking of Google Analytics
- Third party click recording
Event Tracking of Google Analytics
Google Analytics (GA) provides a handy to record clicks and events. As most of the sites already have GA installed it becomes easy to use its event tracking.
Syntax for the recording function is
._trackEvent(category, action, optional_label, optional_value)
category(required) The name you supply for the group of objects you want to track.action(required) A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.label(optional) An optional string to provide additional dimensions to the event data.value(optional) An integer that you can use to provide numerical data about the user event.
For example if you need to record clicks on a link following will be the code.
<a onclick="pageTracker._trackEvent('Page', 'Click', 'My Link')" href="#">My Link</a>
Here pageTracker is GA’s main object that is used to track page views etc. If you are not using standard GA JavaScript code this might have different name.
The code to work properly you ensure that pageTracker is available other wise the code will generate error. Also it is good idea to write a custom function to use _trackEvent. For example you can create a JavaScript function and call this function in your links. In this function you can write code to call _trackEvent.
The function can look like this
<script>
function myTracking(category, action, label, value){
if(typeof(pageTracker)!='undefined'){
pageTracker._trackEvent(category, action, label,1);
}
}
</script>
The above function will not generate error if pageTracker is not initialized properly.
Official documentation can be found at http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html