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
<script> | |
// time how long user spent on page | |
// following this example - http://stackoverflow.com/a/16046028 | |
var timeStart = new Date().getTime(); // time when user arrives | |
window.onbeforeunload = function(){ | |
var timeEnd = new Date().getTime(); // time when user leaves | |
var timeDif = parseInt(timeEnd - timeStart, 10)/60000; // calculate difference in minutes | |
amplitude.logEvent('User Left Page', {'time_spent_minutes': timeDif}); | |
}; | |
</script> |