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);
})
})
}
@ngengs
Copy link
Author

ngengs commented Jun 28, 2016

Some people in this h5ai issue https://github.com/lrsjng/h5ai/issues/171 want to count download.
I think its possible with google analytic event, of corse you must enable google analytic in conf/options.json

For include this script just copy this script to your ext directory public/ext
And after that include this script in your conf/options.json

@akhilnarang
Copy link

Cool 👍

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