How can I code a counter of the total number of unique visitors in a website without using google analytics or other similar platforms. Is there a way to detect a new visitor in JavaScript and send it to my database? (I use firebase). How to detect the fact that a visitor already visited my site?
Thankyou.
Here's a few things you can do:
You can check the IP, that might work, but an IP can be shared by more than one user. A cookie could be a viable option, but a cookie can expire or be modified by the client.
In your case, if does not seem to be a big issue that the cookie is modified you could use a cookie in a case like this. When the page is loaded, check if there is a cookie, if there is not, create one and add a +1 to views. If it is set, don't do the +1.
Set the cookies expiration date to whatever you want it to be, week or day if that's what you want, and it will expire after that time. After expiration, it will be a unique user again!