Tracking documents and external links in google analytics
– posted February 14th, 2007 by Colm McBarron Comments (6) for Tracking documents and external links in google analytics
Following on from my previous post on tracking documents with google analytics, I've updated the javascript to now track external links as well as non-html documents
Installation instructions for the script are the same, all external links will appear as if they were in a directory called 'exlinks' on the top level, then they're divided by their host name and the rest of their url.
So if you have a link to www.iqcontent.com and www.iqcontent.com/blog/ in your site, clicks on these links will be recorded in Google Analytics as:
/exlinks/www.iqcontent.com
/exlinks/www.iqcontent.com/blog
The updated script is available as a free download
It would also be a good idea to add a second profile with just external links in it, and exclude them from the main profile, as if you have a lot of external links this will skew your page view numbers.
Digg this post Submit to del.icio.us Submit to technorati
Category: Web analytics


6 comments so far
1. Kylie on March 15th, 2007 - 4:14AM
Thanks for the great script! It has worked perfectly for recording hits to the pdfs on my website.
I was hoping you might tell me how I can exclude all external links from my main profile and customise a second profile so that it includes these external links.
2. Peter on May 30th, 2007 - 6:04PM
Thanks for the script, but does it work if I use onClick="MM_openBrWindow('http://anothersite.comw/page.html','','scrollbars=yes,width=780,height=620') ... to open another browser window? I tried adding the JS file and the line right above urchin line but so far it hasn't captured any links clicked.
Thanks for the help,
3. Colm on May 31st, 2007 - 9:59AM
@ Peter,
The script won't track that link, it only tracks standard a href links, it checks a page for the href attribute.
You'll need to modify your script for opening a new browser window to include a href value.
4. Webber on June 1st, 2007 - 7:59PM
Hi Colm,
I have being using your script for the last few months and it has been working fine - great job!
But I have noticed that all of a sudden as off end of April for no reason it is no longer recording all downloads from our site. In particular one page has 20 pdf documents, and there is no information regarding these PDF downloads in GA now since end of April. GA script code has not changed, and if I do a filter for /exlinks in GA it still finds some results but very limited compared to the results before end of April.
Any idea on what has happened?
5. John on July 13th, 2007 - 11:15AM
IT doesn't seam to be tracking our links very well either. Only gets hits from firefox and safari. any ideas why?
6. Josh Katinger on July 22nd, 2007 - 6:47PM
"It would also be a good idea to add a second profile with just external links in it, and exclude them from the main profile, as if you have a lot of external links this will skew your page view numbers."
...might be nice for your readers if you also added some tips on creating said filters...just a thought.