Created
June 28, 2016 17:45
-
-
Save ngengs/f868b098e2aa38b88aa270dd24c883dd to your computer and use it in GitHub Desktop.
h5ai external script to detect item click, and push to google analytic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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