P
P
Pogran2017-03-18 16:29:17
JavaScript
Pogran, 2017-03-18 16:29:17

How to find out the amount of time a user stays on the site?

I want to determine how much time the user spent on the site. For example, if a user visits the site for the first time (how to determine that it is your first time?), I want to display a message to him in 5 minutes. Then, every 10 minutes, again display information within the framework of this session. If the session is closed, then when the user enters the site again, define it again as a new one

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-03-21
@webinar

How can you tell if it's your first time?

The easiest way to do this is in a browser. To do this, there is localStorage, we save the entry date in it (there is an entry date - it means the user has already been, there is no entry date - it means he was not).
I want to display a message to him in 5 minutes.
Either the timer is normal or the timer + sessionStorage, which is cleared when the tab is closed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question