1

I'm searching on how to track time spent by a user in a webpage of my django app. I would like to store this time in the database in a column next to the username. I've checked many solutions posted here but they seem very complicated for my app.

Any suggestion?

Thank you

Tim
  • 47
  • 2
  • 8
  • Could you please show what you've found and describe why it's complicated? Maybe it's better to implement a tracker on a client side with JavaScript and DOM and send results before loading each page and before closing a page to the server which runs Django app? – hsrv Jun 08 '16 at 14:05
  • Can you just place a repeating timer in your javascript that makes an AJAX call to your web service. At which time, the service updates the total time spent? – SteveJ Jun 08 '16 at 14:39
  • Thanx you guys for the feedback. I was following the example of TimeMe.js in this link: [link]http://stackoverflow.com/questions/4667068/how-to-measure-a-time-spent-on-a-page Unfortunately I don't understand the part that the data collected from tracking are stored: window.onbeforeunload = function (event) { xmlhttp=new XMLHttpRequest(); xmlhttp.open("POST","ENTER_URL_HERE",false); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var timeSpentOnPage = TimeMe.getTimeOnCurrentPageInSeconds(); xmlhttp.send(timeSpentOnPage); }; – Tim Jun 08 '16 at 17:31

0 Answers0