ASP.NET MVC: Page Tracking Views and Browsing Duration

I have an application in which I am currently working, this requires that administrators can track ticket views and its duration.

I have a tracking number of views by users sorted, I have a table that contains TicketID, UserID and DateOpened. Each time a user visits the page, a new line will be inserted.

However, the way to track the duration of views is to have a DateClosed field in the table, which will allow me to work out the duration of the view in the code, rather than directly store the time.

I can’t use Google Analytics or any third party for this task or because of an internal policy, like for an intranet application.

What would be the best way to get this field populated on page exit?

+3
source share
1 answer

Before the window "unloads", just make an AJAX call.

window.onbeforeunload = function() { //do ajax call }
+8
source

Source: https://habr.com/ru/post/1756597/


All Articles