Skip to content

Instantly share code, notes, and snippets.

@ngengs
Created June 28, 2016 17:45
Show Gist options
  • Save ngengs/f868b098e2aa38b88aa270dd24c883dd to your computer and use it in GitHub Desktop.
Save ngengs/f868b098e2aa38b88aa270dd24c883dd to your computer and use it in GitHub Desktop.
h5ai external script to detect item click, and push to google analytic
if(window.jQuery){
//run when window ready
$(window).ready(function(){
//detect item click
$('body').on('click','.item.file>a',function(e){
var f=$(this);
// Test the function, print the download/clicked file to console
console.log("Downloading:"+f.context.href);
ga('send', 'event', 'File Sharing', 'Download', f.context.href);
})
})
}
@akhilnarang
Copy link

Cool 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment