So I’ve taken the code and modified it a little to make it just for
file downloads, and to cover more file extensions that the original.
This will track the following file types:
- PDF (.pdf)
- Microsoft Word (.doc)
- Microsoft Excel (.xls)
- Microsoft PowerPoint (.ppt)
- Microsoft Visio (.vsd)
- Microsoft Visio XML (.vxd)
- ZIP Archive(.zip)
- RAR Archive (.rar)
- Text file (.txt)
- Downloadable CSS file (.css)
- Executable (.exe)
- NEW Windows Media Audio (.wma)
- NEW Quicktime (.mov)
- NEW Audio Video Interleave (.avi)
- NEW Windows Media Video (.wmv)
- NEW Mpeg Layer-3 (.mp3)
place it somewhere on your webserver and paste the following code
directly above your standard Google Analytics tracking code (which by
the way, should be as near the end of the <body> tag as possible).
Hey presto you’ve now got tracking for all downloadable files!
throw a wobbly if there are anchor links on the page, also some new
file types have been added (see above).
UPDATE: The script now tracks external links as well as document downloads.