Skip to content

Commit 068fac1

Browse files
committed
Merge pull request #33 from sjrd/download-analytics
Download analytics, also for same-page links
2 parents 70523ae + 169561b commit 068fac1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

_includes/headerbottom.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,24 @@
3131
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
3232
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
3333
})();
34-
34+
var f = function(event){
35+
var href = $(this).attr('href');
36+
var target = $(this).attr('target');
37+
_gaq.push(['_trackEvent','Downloads','Download',href]);
38+
if (target === undefined || target.toLowerCase() != '_blank') {
39+
setTimeout(function() { location.href = href; }, 200);
40+
return false;
41+
}
42+
};
43+
function endsWith(str, suffix) {
44+
return str.indexOf(suffix, str.length - suffix.length) !== -1;
45+
}
46+
$(function(){
47+
$('a').filter(function(){
48+
var href = $(this).attr('href');
49+
return !endsWith(href,'/') && !endsWith(href,'html');
50+
}).on('click',f);
51+
});
3552
</script>
3653
</head>
3754
<body onload="styleCode()">

0 commit comments

Comments
 (0)