Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add visitor counter to footer #26

Open
VickiLanger opened this issue Dec 3, 2021 · 2 comments
Open

[FEATURE] Add visitor counter to footer #26

VickiLanger opened this issue Dec 3, 2021 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@VickiLanger
Copy link
Owner

It would be cool if we had a visitor counter at the bottom. I'm imagining a '90s-esque counter

@VickiLanger VickiLanger added the enhancement New feature or request label Dec 3, 2021
@VickiLanger
Copy link
Owner Author

We could use something like this, but isn't local storage just local to a browser? Would this count across everyone or just be a count of how many times an individual browser had visited the site?

var counterContainer = document.querySelector(".website-counter"); // get the div
var visitCount = localStorage.getItem("page_view"); // get views from localStorage

if (visitCount) { // if page_view does exist
  visitCount = Number(visitCount) + 1; 
  localStorage.setItem("page_view", visitCount); //update localStorage
} else {  //if page_view doesn't exists, create it
  visitCount = 1;
  localStorage.setItem("page_view", 1); //Add entry for key="page_view"
}
counterContainer.innerHTML = "Views: " + visitCount; // set the page counter
/* Styles for website counter container */
.website-counter {
  font-family: var(--text-font);
  background-color: var(--heading-color);
  height: 50px;
  width: 280px;
  color: var(--dark-color);
  border-radius: 0.3rem;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: .075rem;
}

@VickiLanger VickiLanger added the help wanted Extra attention is needed label Dec 3, 2021
@VickiLanger
Copy link
Owner Author

Used a prebuilt one to start with. I'd still prefer to build one just for OpenGates. Long term, I'd rather not rely on someone else's code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant