Skip to content

Commit

Permalink
Added unique visitors count
Browse files Browse the repository at this point in the history
  • Loading branch information
ygowthamr committed Nov 10, 2024
1 parent d3eca41 commit 04f0cbd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions visi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ function getVisitorCount() {

// Function to increment and save the count
function incrementVisitorCount() {
let count = parseInt(getVisitorCount()) + 1;
localStorage.setItem('visitorCount', count);
return count;
if (!localStorage.getItem('visitedHomePage')) {
let count = parseInt(getVisitorCount()) + 1;
localStorage.setItem('visitorCount', count);
localStorage.setItem('visitedHomePage', 'true');
return count;
}

return getVisitorCount();
}

// Function to display the count
Expand Down

0 comments on commit 04f0cbd

Please sign in to comment.