From d26c8b8d8bae814ba1fc05369aeb0add5265ebb3 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Fri, 1 Mar 2013 14:36:40 +0100 Subject: [PATCH] analytics for downloads and other non-html-links --- _includes/headerbottom.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/_includes/headerbottom.html b/_includes/headerbottom.html index 52a046fcf..34664f6f0 100644 --- a/_includes/headerbottom.html +++ b/_includes/headerbottom.html @@ -11,7 +11,18 @@ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); - + var f = function(event){ + _gaq.push(['_trackEvent','Downloads','Download',$(this).attr('href')]); + }; + function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } + $(function(){ + $('a').filter(function(){ + var href = $(this).attr('href'); + return !endsWith(href,'/') && !endsWith(href,'html'); + }).on('click',f); + }); \ No newline at end of file