Adding Google Click Tracking code to all file_download links

Permalink
I want to add the Google click-tracking code to the file links that my users add through the content editor. I could teach them how to add it manually, but they are numpties and it'd be much easier if I could find a way to add it for them automatically, thus changing links that look like this:
...
<a href="http://www.mywebsite.com/index.php/download_file/100/69/">my_file_name.pdf</a>
...
into links that look like this:
...
<a href="http://www.mywebsite.com/index.php/download_file/100/69/" onclick="_gaq.push(['_trackEvent', 'PDF Download', 'Download', 'Download of file - my_file_name.pdf']);">my_file_name.pdf</a>

Any ideas how I could do this?

juliandale
 
Remo replied on at Permalink Reply
Remo
I think you could build a simple package with an on_start method and simple call addHeaderItem to run a small JavaScript code to add the onclick attribute.

Are you familiar with building packages?
webchris replied on at Permalink Reply
webchris
Another solution is to use Google Tag Manager and assign a class or ID to the link that tag-manager can pick up.