1
I need to take the time that the user was on a given page, and the user leave the page, this time is recorded in the database.
Would anyone have any idea how to do?
[Edited]
The time I managed to get using javascript. The problem is recording this access time in the database. I tried to use the following code to send the access time via POST and then capture and insert via mysql, but it didn’t work:
<form action="post" id="register_access">
<input type="hidden" value="1" name="access_time" id="access_time"/>
</form>
<script>
var contador = 0;
setTimeout(temporizador,1000);
function temporizador() {
if(contador < 10000000){
setTimeout(temporizador,1000);
}
document.getElementById('access_time').value = contador;
contador++;
}
jQuery(document).ready(function($){
$(window).on('beforeunload', function(e) {
$('#register_access').submit();
//return 'Are you sure?';
});
});
</script>
This would be done with javascript
– Ricardo
It’s a website, or a system?
– KaduAmaral
In this case it would be a Kaduamaral site...
– robssanches
Why don’t you use the Google Analytics?
– KaduAmaral
I need to record the access time in my database. Google Analytics does not roll pro that I want to do Kaduamaral... still worth.
– robssanches