2

I have Django project and several views. In one view i want to track users spent time. How can i do that? Maybe some libraries or django built in methods?

Little bit more about view:

when user open view he can see many photoes, and then he need to choose similar and save. Then page reloads with new photoes and task is similar, find similar photoes and submit.

I need to track and store that time what each user spent on this task.


If i check users time when he open view i don't know when she close it, and also user can just open view and chill, without doing something.


How or with i can realize it?

Dmiich
  • 325
  • 2
  • 16
  • This is a very good question on time-on-site metric for web apps. But, this cannot be computed server-side (Django) effectively because all the user interactions happen at client side. Hence JavaScript or a combination of JS with server will be very efficient for this. I can guide you with sample code on JS side. There are several SO posts on this request. Let me know if that helps. – webblover Aug 19 '22 at 07:05
  • 1
    If You are able to paste some somple code I would appreciate it @webblover – Dmiich Aug 20 '22 at 08:05
  • Here is a detailed answer by me in another post, take a look at here [https://stackoverflow.com/a/73384593/1786360](https://stackoverflow.com/a/73384593/1786360) – webblover Aug 22 '22 at 04:23
  • 1
    Does this answer your question? [Track user time in completing a particular action in a website](https://stackoverflow.com/questions/50698676/track-user-time-in-completing-a-particular-action-in-a-website) – webblover Aug 23 '22 at 06:52
  • It helps but also is a lot to do. So I will try to implement. Thanks – Dmiich Aug 23 '22 at 09:38

1 Answers1

2

Sorry wasn't able to comment but hope this helps:

  • Make use of Django sessions 'django.contrib.sessions to check the user session (start and stop)
  • Use JavaScript & jQuery to track the time spent and
  • also check mouse events/key events to make sure the user actually does something
imran.ke
  • 50
  • 1
  • 10