Tracking links to direct downloads – Automatically
[This hack is for the legacy urchin.js tracking code.
Always refer to the Scripts & Downloads section for the latest version.]
April 2011 – New async hack launched
This hack has been completely revise for the latest GA async code. Further info >>
The script works by looking for links within the browser’s Document Object Model (DOM) that match the file extension given in the variable array
extDoc. If so it is modified to include the urchinTracker call. By this method, all file downloads will be reported as:
...your remaining web page content...
A note on performance: Each time your page loads, this script will go through all links referenced on the page to see if it is for a download. Clearly the more links on your page, the harder the script must work. As long as the number of links on each page number in the hundreds and not thousands, performance should not be a problem. Also, pages with a large number of links, it is possible that visitors will click on a download link before the script has modified it. The result is that click through will not be tracked by Google Analytics.
I have now combined this hack for downloads with the Tracking of banners and other outgoing links - automatically into a single file that is available in the Scripts & Downloads section.
Did you find this tip useful? All tips are being grouped under the category GA Hacks. Please provide your feedback with a comment.