Tracking more than just pages with Google Analytics

A long overdue blog post!  The modifications below will enable you to track email links, document downloads & outbound links on your site with Google Analytics.  There are other ways to do this (such as using Event Tracking) but this is the simplest way & can be then used to add goals into your Google Analytics profiles.

Please note: the code here is correct for the “Async” version of Google Analytics.

Tracking Email Link Clicks

Google Analytics can track clicks on outbound links & email links with a small update to the code around the link.  We tend to use automated systems that come from the plug-ins within WordPress – our preferred CMS of the moment.  However, if you cannot setup this up then you can use the modification below to track your email links:

Original Link

<a href=”mailto:email-address@company.com”>email-address@company.com</a>

Updated Link

<a href=”mailto:email-address@company.com” onClick=”javascript: _gaq.push([‘_trackPageview’, ‘/email/contact-page’]);”>email-address@company.com</a>

When you review your content report the click on the email link will show in there under the page view that you set in the code above.  You can then add this as a goal into your Google Analytics reports.

Tracking Downloads

We can also use the same modification for downloaded documents such as PDFs, doc files etc.  Again we normally use a plug-in for Wordpress that automates this function but the manual method is shown below:

Original Link

<a href=”http://www.example.com/files/map.pdf”>Download the map</a>

Updated Link

<a href=”http://www.example.com/files/map.pdf” onClick=”javascript: _gaq.push([‘_trackPageview’, ‘/downloads/map’]);”>Download the map</a>

Tracking Outbound Links

Want to understand which links people are using to leave your site?  This quick modification will show you which of your outbound links are the most popular.  Again this information is viewable in your Top Content report & goals can be setup if you wish to track the outbound links:

Original Link

<a href=”http://www.other-site.com”>Click here for other site</a>

Updated Link

<a href=”http://www.other-site.com” onClick=”javascript: _gaq.push([‘_trackPageview’, ‘/outbound/other-site.com’]);”>Click here for other site</a>

If there are any other modifications that you’d like to see here please request them below & I’ll follow up this post with any requests!

Google Analytics v2.0
Creative Commons License photo credit: vrypan

Leave a Reply

Your email address will not be published. Required fields are marked *

3 thoughts on “Tracking more than just pages with Google Analytics”

  1. Nice and to the point. You should write the event tracking method..for dummies as well.nand warn about padded fake page views.

    • Attacat Ben says:

      Thanks – in the next instalment I’ll provide the alternative using Event Tracking & explain the pros and cons of each method.n

  2. Emy says:

    This is great! I’ve been searching for ways to track those email links I have set up. Now, I’ll just have to see if that code works for my blogger blog.

Like the Brain? Sign up for the packed-full-of-tips monthly newsletter