Can you tell me how django can be used to track the time a user spent on a page in milliseconds, for example?
CodePudding user response:
One way could be to make your Javascript note down the time when the page loads and also the time when the page unloads(using window.onbeforeunload
) and then send this data to your Django backend. Then your backend can calculate the time spent on the page.
Or you can go with the good old method of making your frontend/client poll your server using ajax calls say every 5 seconds so that you will know that the user has spent atleast as long as you got the requests.