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 hidden or 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
Cool 👍