Monday, 28 February 2011

catching click event for download files for stats

We use the Urchin ver 6 to have the stats of our CMS system. We wanted to have the data in house rather than let google keeps it for us.
Our CMS system has a security layer that before allowing someone download a file (PDF, DOC etc..) perform verfication and then redirects to download the file that operation isn't recoreded in the web server log that used by Urchin and therefore we couldn't record the files been downloaded.
I found the following post providing with a solution. What they suggest is simple when the page is loaded we run a javascript code that add a click event to perform the urchinTracker javasript, which in return will write to the web server log the filename been downloaded.
This javascript code also allow to record clicks on mailto link, but I haven't tested this option.