Visitor Counter

I would like to put a simple Visitor Counter on our main page. Don’t really care who they are/where they are from. Would prefer not to double count them if they go back to the main page to select another page.
Your suggestions/help are appreciated.
Bobby
HEART Radio Team

You can use local storage .

Use setItem to save an item that indicates that the visitor has already visited the site:

local.setItem("visited", "yes");

Use getItem to get the item. If the item exists, the visitor has already visited your site, If the item does not exist, then they’re a new visitor. You can do something like this to check:

let value = local.getItem("visited");
if(value === 'yes') {
   // visitor has already been here before
}
else {
   // new visitor, so update the counter
}

Or, you can even make the check simpler:

let value = local.getItem("visited");
if(value === null) {
   // the item was never saved, so this is a new visitor
   // update the counter
}

I understand about the 3 type of local storage (local, session, memory), at least I think I do. However, when looking at keeping an ongoing count for the number of visitors, where can I store the current count ?
Example if they do not have a “visited” indicator for SESSION, then I want to get the latest count, increase by one, save the new number, then display on the screen. I understand that in this scenario, if they came back to the site a couple of days later, they would be counted again. This is what I want. BUT, …
Where can I store the “count to date” so that other visitors get counted as well?
Thank You.