Track File Downloads & Outbound Exit Links Automatically

Share Button

What this Google Analytics Plugin does

Automatic tracking of file downloads and outbound exit links links in Google Analytics – without the pain of modifying each link manually across your site. Aimed at webmasters, this JavaScript plugin scans all your page links for you in the background, and automatically adjusts them accordingly for Google Analytics by automatically adding an onClick event handler for you. There is also the option to modify the bounce rate calculation. Read the blog post. Summary of features:

As you may know, I wrote the original file download and outbound link tracking script back in 2007. Things have moved on since then. This Plugin has been completely rewritten for the ga.js async code, with more flexibility, better performance and improved browser compatibility.

Also try this with the Customising the SEO list for Google Analytics plugin.

Usage

Easy Install

  1. Purchase either the Standard or the Developer version of the automatic plugin to receive the JavaScript file.
  2. Upload the .js file into your website root directory (used in this example) or other suitable place
  3. Modify all your web pages (once only change) to reference the .js file above your Google Analytics Tracking Code.
  4. That’s it… Or perhaps you thought there was more!

Example GATC – the only line added is #1. The rest is your remaining tracking code:



You can view the new GA calls in your Real-Time reports, or by using the the GA Debugger extension for Chrome (see item #4 of my post The Best Google Analytics Addons).

In your standard reports, allow approx. 4 hours for your reports to be populated with the new information. To view these, log in to your Google Analytics account and goto ‘Content > Site Content > All Pages’ report (for virtual pageviews – see below image), or ‘Content > Site Content > Events > Top Events’ report (if you have configured it for event tracking).

For virtual pageviews, the data is shown in the Content/Site Content/All Pages report

If you are combining this with the Custom Search Engine Hack, your GATC will look like the following (lines #1,2 and 7 are the changes):




Who uses this…?

Small businesses, universities and blue-chip clients rely on this plugin…

clients using the Google Analytics plugins

Feedback

As always, I appreciate feedback. Feel free to suggest new features. Also, check out the Custom Search Engine list for Google Analytics plugin.

Share Button

Comments

  1. Hi Brian,

    I wrote an article on how to do this using the new version of Google Tag manager V2 and GTM Variables. It tracks downloads as events, but could be configured for jsut about anything, E.g. Clicks on specific elements on the page.

    It may be helpful for the others not wanting to inflate pageviews.

    You can check it out here: Track File Downloads in Google Analytics using Google Tag Manager

    • @Peter – thanks for comment. GTM is definitely the way to go now. My plugin is for the legacy “classic” GA implementation method. I advise all to move to GTM and make your life so much more simple…

  2. Aris says:

    Hi Brian,

    Can I run the script with Google Tag Manager? If yes how?

    Thank you,

    Aris

    • @Aris – I don’t see any issue using Google Tag Manager or any other tag management solution – its just a call to another javascript file. FOr GTM the custom HTML tag is the way to go.

  3. Ryota says:

    Hi Brian,

    We want to roll up this report into Event Tracking on Google Analytics to avoid inflating pageviews.

    If we use your script, will we have the ability to control the Category, Action and Label parameters?

    Thanks,
    Ryota

  4. I’ve implemented this plugin and 47% of the tracked outbund clicks/events have event label = undefined. What’s that?

    Also 41 out of 776 events tracked are internal clicks.
    Site is http://www.visitaland.com (and m.visitland.com).

    Strange.

    • @Jonas: whenever a href attribute does not point to a real http link you will see undefined because the link is not “real”. So for example, I found this in your html:

      ¤
      
      

      Because the href is pointing to a js (rather than to a webpage), the plugin does not know what to do with it.

      HTH

  5. Vivian says:

    Is it possible to use this code on individual html pages of site instead of in a master layout that contains the Google Analytics code?

  6. Nathan says:

    What a great plugin. I am really getting into finding tools to use to help track and improve conversion optimisation on client sites.

  7. paul says:

    You forgot to say (1A) that one’s domain name **does** have to be put inside the js file by editing, its omitted from this instruction page here but is in the js file instructions.

  8. Greg says:

    Brian, will this track clicks on phone numbers from mobile devices (those are not href links in HTML)? Does Standard version can utilize tracking via Events?

  9. Vlad says:

    Doesn’t work with links within flash, right?

  10. Nick says:

    Great resource at a very fair price Brian. Supposing you have a site with multiple outbound links under different categories. Is there an elegent way to capture those categories in the Category field for event tracking?

  11. Christine S. says:

    Maybe you said this and I didn’t see it, but can you track MP3’s with this?

    • Christine: The Developer version will allow you to set any file extension to track.

      As I am still working on the Developer version, I would be happy to add MP3 support to your standard version for now at no extra cost. Just go ahead and purchase and I will look out for your order

  12. Stanley Z. says:

    Good work Brian. I’m not that technical, so how monkey-proof is it. Can I offer it to my clients without getting techical questions in return. In other words, what’s the experience in the real world?

    • Stanley: As you can see form the setup I have posted, its pretty straightforward to install. That said, a webmaster who understands html and javascript should be the one to install this script.

  13. Antti Nylund says:

    I reckon you have sorted the case where outbound links already contain onClick event?

  14. Nick says:

    What about if outbound links are internal redirects (PHP redirect, 302/307 redirects, etc) such as mydomain.com/outboundlink.php – would each link have to be manually tagged as such, or will this hack “auto-detect” these as outbound links?

    • Nick: That won’t work as the href element of the link will still be pointing to your-domain.com. That is, the hack will not see the outbound link as that only appears server-sider after the click-through.

      Is there a specific reason why you are handling outbound links in this way? It sounds counter-productive from a user-experience point of view i.e. users like to know if they are clicking an outbound link first…

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Buy the Book

From here Amazon E-book only

Looking for Successful Analytics?

Launched January 2015, the latest book is Successful Analytics. Its a manager's guide to gettings things done right, understanding the process and getting results.

Take a look and buy

From here

Connect with me:
icon-linkedinicon-twittericon-googleplusicon-rss

© Brian Clifton 2015
Best practice privacy statement