If you have Google Analytics setup on your site then it is definitely recording pageviews. If you are not using it then you can add script easily with All in One Webmaster WordPress Plugin.
But what if,
- You have to track special click events?
- You need to track an event in google analytics when someone fills out a form and clicks submit?
So, what is event tracking?
Event Tracking is a method available in the ga.js tracking code that you can use to record user interaction with website elements, such as a Flash-driven menu system. This is accomplished by attaching the method call to the particular UI element you want to track. When used this way, all user activity on such elements is calculated and displayed as Events in the Analytics reporting interface. Additionally, pageview calculations are unaffected by user activity tracked using the Event Tracking method. Finally, Event Tracking employs an object-oriented model that you can use to collect and classify different types of interaction with your web page objects.
Other must read:
- “Placed” analytics added to “All in One Webmaster” WordPress Plugin
- 5 cool & useful jQuery Tips, Tricks & Solutions
So why this post now?? To be honest, I wasn’t using this feature until last month. But as traffic increased to ~55k/day, I thought of using it lately and found really interesting metrics in Google Analytics.
Let me first share my Social Media code which I’m using in widgets (I’m not using any WordPress Plugins):
<ul id="social"> <li><a href="http://twitter.com/Crunchify" id="tw" onclick="_gaq.push(['_trackEvent', 'Outbound', 'Footer', 'Twitter']);" rel="nofollow" target="_blank">Twitter</a></li> <li><a href="http://www.facebook.com/Crunchify" id="fb" onclick="_gaq.push(['_trackEvent', 'Outbound', 'Footer', 'Facebook']);" rel="nofollow" target="_blank">Facebook</a></li> <li><a href="https://profiles.google.com/106055458173231548502/about/?rel=author" id="plus" rel="me author" onclick="_gaq.push(['_trackEvent', 'Outbound', 'Footer', 'Google-Plus']);" target="_blank">Google+</a></li> <li><a href="https://crunchify.com/feed/" id="rss" onclick="_gaq.push(['_trackEvent', 'Outbound', 'Footer', 'Rss']);" rel="nofollow" target="_blank">RSS</a></li> </ul>
Yes, we are looking at onclick() event and _trackEvent() method. There’s no need to change your scripts, or set a section up in your Google Analytics dashboard. All you need to do is add code to the link, and it automatically starts tracking within your dashboard.
onclick="_gaq.push(['_trackEvent', 'Outbound', 'Footer', 'Twitter']);" _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
- 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.
- non-interaction (optional): A boolean that when set to true, indicates that the event hit will not be used in bounce-rate calculation.
Now what? View the reports. Once event tracking has been set up and working on your site for a day, go to the Content section of the reports and view Event Tracking. Unique events will show you how many visitors triggered a particular event.
jQuery
So far, we just focused on links, but jQuery opens up the whole DOM to interactions. Here’s an obvious use to automatically apply a download action to any links that are ZIPs:
$(document).ready(function() { $('a[href$="zip"]').click(function() { _gaq.push(['_trackEvent', 'ZIP Downloads', 'Download', $(this).attr('href')]); }); });
I highly recommend using this Google Analytics feature. What functions are you using in Google Analytics to see how your visitors behave on your site, and what actions are you taking to help them along the path from search to purchase? I’d love to hear your ideas!