Chuck Self posted on March 16, 2009 13:00
Google Analytics is a great free tool for tracking website traffic, but one of the little known facts that is that you can track much more than just site visits, page views and bounce rate.
Did you know that you can also track outbound links from your website to another site or when someone opens a local resource file (i.e. PDF file, Word Document, Image, etc.) from your site?
DotNetNuke has the functionality built in to track Link Click’s. The problem is that the DNN solution doesn’t create properly named links for SEO (Read a great article detailing this by Seablick). Also, I believe that it’s important to analyze your Google Analytics data with your link tracking in one place (it makes things a lot easier to see).
Why is link tracking so important?
There are so many different reasons why tracking outbound and file links and clicks are vital for you in understanding your website trends. If your don’t have an all encompassing view of how people are coming to, what they are clicking on and how they are leaving your website then you don’t know what you need to improve on. How do really gauge success without all the facts.
Below are few real world examples.
-
You write a Blog that’s primary purpose is to promote a white paper in PDF form.
If you just track page visits then you will see how many people clicked on the Blog post, but you wouldn’t have any idea of how people actually clicked on the white paper.
It’s important to have both metrics. If you have 100 people click on the blog post, but only 5 people click through to the white paper, then did you really get the information out there? Without both numbers it's hard to tell.
-
Your website refers people to other websites.
For example, I recently wrote a blog where I had an external link to a hosting company. I wanted to track how many people actually clicked the link to find out more about this hosting company. So I simply added the tracking script to the link.
My Google Analytics reports then showed how many people click that specific link. If you do any referrals, then wouldn’t it be great for you to be able review the number of times that you refer someone to another website.
It is so important to know what resources people are looking at (or not looking at)? You may need to redesign a page or a blog. You might need to create an image to grab people’s attention better or highlight the link more prominently. Bottom line is, if you don’t have the right statistics then you don’t know how to improve.
Some background on Google Analytics Link Tracking.
Google Analytics provides an easy way to track clicks on links that lead away from your site. Because these links do not lead to a page on your site containing the UTM JavaScript, you will need to tag the link itself. This piece of JavaScript assigns a pageview to any click on a link - the pageview is attributed to the file name you specify.
For example, to log every click on a particular link to www.anydomain.com as a pageview for "/outgoing/anydomain_com" you would add the following attribute to the link's tag:
<a href="http://www.anydomain.com" onClick="javascript: pageTracker._trackPageview('/outgoing/anydomain.com');">
It is a good idea to log all of your outbound links into a logical directory structure as shown in the example. This way, you will be able to easily identify what pages visitors clicked on to leave your site.
Important: if your pages include a call to _trackPageview, _setAllowLinker _trackTrans(), your Analytics tracking code must be placed in your HTML code above any of these calls. In these cases the tracking code can be placed anywhere between the opening <body> tag and the JavaScript call.
To verify that _trackPageviewis being called correctly, you can check your Top Content report 24-48 hours after the updated tracking code has been executed. You should be able to see the assigned pagename in your report.
How to add this to DNN.
1. Open up any Text/HTML module (or any module that contains a Rich Text Editor).
2. Add your content as usual.
3. Highlight the link text or image and select the “Insert/Edit Link button” from the editor.
4. Type the URL and specify any target or advanced settings and click OK.

5. Now press the Source button on the editor.

Now all you have to do is add the “onClick” Analtitcs tracking code mentioned earlier in this post.

Don’t forget to Update your page and then you are done. Now every time someone clicks on the above link, it will create a page view link in my Google Analytics reporting for “/outgoing/anydomain.com”.
I hope this demonstrates how easy it is to enhance your Google Analytics to include link tracking.
Please let me know what you think about this method or has tracking links this way helped improve your ability monitor all aspects of your incoming and outgoing website traffic.