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?
...
<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?
Are you familiar with building packages?