I would like to somehow (possibly with the "onload" and "onunload" functions) discover how long individual visitors are spending at a site. Have a mySQL back end, so there is somewhere for the data to be sent...
Any ideas?
cheers, H
| SitePoint Sponsor |
I would like to somehow (possibly with the "onload" and "onunload" functions) discover how long individual visitors are spending at a site. Have a mySQL back end, so there is somewhere for the data to be sent...
Any ideas?
cheers, H
~The Artist Latterly Known as Crazy Hamster~
922ee590a26bd62eb9b33cf2877a00df
Currently delving into Django, GIT & CentOS





I'm pretty sure that isn't possible with JavaScript or similar - you can't send the data the java generates on the client to the MySQL backend on the server.
You would need to use PHP or similar, although the best way would be to find a log analyzer that can work out the average time a visitor spends on your site directly from teh weblogs.



I think it would be possible to use the onload and unload functions. The only way I can think of a way to get total time spent on the site and not on individual pages would be to have a hidden frame.
The start time could be given by calling a JavaScript source file (like js.php), this could assign the user a unique value. When the user exits the site (and the frame closes), a "goodbye" popup could be displayed, after passing the time spent on the site to a php script. Like window.open (... "timer.php?total=" + totaltime + "&user=" + initialphpscriptgivenvalue + "&extrainfo=" + extrainfoaboutbrowseretc );
hmmm - Have to give this one some thought. Thanks for the advice.
H
~The Artist Latterly Known as Crazy Hamster~
922ee590a26bd62eb9b33cf2877a00df
Currently delving into Django, GIT & CentOS
Bookmarks