Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
It is impossible to calculate this time completely correctly (unless you send data to the server about all the movements and clicks of the user on the page - and not just about those that initiate some kind of communication with the server).
You can calculate a little more correctly by analyzing all client requests to the server yourself. Let's say the user opened the signup form at 10:00. We know that it takes an average of 2 minutes to fill it out. At 10.10 the user clicked on "Register". Most likely, he actually spent about two minutes on the site (distracted by something else) than all ten minutes.
In theory, by compiling a table where the average time of working with a particular page / action will be written + analyzing the logs, you can more or less correctly calculate the time a person works on the site.
In one of the projects to which I am related, we count the time using a similar algorithm, however, our plate is rather simplified. But we need to know the time only approximately.
But maybe there are online services that can do this. Maybe someone else can advise.
Most likely you will have to pervert yourself a little for this. because the only way to verify such "single views" is to constantly poll the user. Accordingly, the simplest implementation is to send a request to the server via ajax once every N seconds. And there inside it will already be considered which page by which user how much it looked with an error of those same N seconds.
Of course, it is difficult to imagine what it will be with good attendance, but if there is a task, there is its implementation)
Look in the direction of Yandex metrics, it seems there was something similar.
There was an idea, but I don’t know how it works, since I have never done this.
After all, time can be counted on the client using javascript and, in necessary situations (for example, following an external link), it can already be sent by Ajax to the server. You just need to hang appropriate handlers on all external links. Well, track when a person simply enters a different URL in the browser line and leaves the site. As far as I know, both can be implemented.
If I were paranoid and wanted to track the time spent on the site as accurately as possible, I would do this:
1. The client connected. We mark the time.
2. On the client side, we open a permanent connection with JavaScript (comet, long-polling, etc.)
3. If the client went to another page, we take into account the time (the time spent viewing that page and the total time on the site) and go to step 1
4. If the visitor hasn't moved the mouse, or hasn't scrolled the page for the Nth time, the javascript terminates the connection.
5. If the client disconnected and did not reconnect within 10 seconds, then it means that he closed the tab or item 4 worked, or he left the tab active and went to drink tea. Stop counting time
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question