Metrics are a key requirement of any marketing or advertising strategy; of course the web is no different. The web offers unparalleled metrics, which can be dissected to an unprecedented level. Making analytics an integral part of the development offers the potential to improve the added value of tracking metrics on a website.
Often I find myself (and see others) dropping in the Google Analytics code as a last piece of housekeeping before setting a project live. This is a fast and easy approach to get a lot of good data, but what if we took an extra hour or so and really integrated our analytics? The power is built into the tool to make tracking pages even more useful.
Recently I have been going through the Conversion University presentations from Google. The capabilities that Google Analytics provides beyond the “easy implementation” are staggering.
One of the biggest uses of Google Analytics I see missing on a great number of sites is Javascript Click-Tracking. With so many websites now using javascript as an integral part of their development process, we seem to miss out on tracking these events. Lightboxes, slide-out trays, and content rotators are all major user interactions with a website, however these often don’t generate movement to another page and therefore do not cause Google Analytics to fire by default.
tracking page views
There are ways around this that Google has provided. Integrating a little bit of tracking code in your javascript can allow you to see them as page views and events in your Google Analytics reports. We have decided to consider many of our lightbox or slide out events as javascripts so we track them with the following code:
pageTracker._trackPageview('/contact-us');
This example shows the code in acutal use. When the user clicks on any element with the class name “contactUs” the script animates in the contact form and initiates a page view for the page “/contact-us”:
$('.contactUs').click(function(){
pageTracker._trackPageview("/contact-us");
$('#contactForm').animate({
width: "439px"
}, 500);
return false;
});
This causes a page view to be catalogued by the analytics. To see this in actual use click here (link to http://www.impulsestudios.ca/portfolio). We actually track each lightbox on the page as well as the sliding contact form. Not only does this allow us to see what our users are interacting with it also gives us a more accurate report of time on page and how users progress through the site. We can now start to look for patterns in how users are interacting with our portfolio (which was previously impossible), which projects are testing the highest, and which ones are more likely to lead to a user contacting us. By doing this, we are able to gather more accurate reports about how users are actually interacting with our websites.
tracking events
Analytics also allows us to track events. Whether it be downloads of a form or an interaction with a video, we simply use the event tracker in the manner outlined below:
pageTracker._trackEvent("Downloads", "PDF", "/salesForms/orderForm1.pdf");
pageTracker._trackEvent("Videos", "Play", "Gone With the Wind");
Of course we are just scratching the surface at this point. Google’s Conversion University offers detailed information on in-depth ways to use Google Analytics including detailed e-commerce and Flash tracking. Google analytics is an extremely powerful tool for gathering metrics. With a little extra work through the development process, analytics can become an even more integral part of our services in the web industry.
How are you using analytics? Follow me on Twitter and let me know, or leave a comment below.
further reading
References
“Google Analytics Tracking API” Google Code. 10 Jun 2009
<http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html>
“Google Analytics Developer Docs” Google Code. 25 Jun 2009.
<http://code.google.com/apis/analytics/docs/>
“Google Analytics IQ Lessons” Google Conversion University. 25 Jun 2009.
<http://www.google.com/support/conversionuniversity/ >.
Tags: Analytics, Development, Google, Javascript, Metrics





Hello, can you please post some more information on this topic? I would like to read more.
Very nice information. Thanks for this.