Resources Page

tools & tips i use for creating my sites

website tools & workflow

How to's:

Terminal tools

Code snippets

Visit counter using CounterAPI

  1. create an account on CounterAPI
  2. create a workspace, and create a counter within that workspace
  3. add this code to your html to update and display visit counter:
<script>
// Counter is available as a global variable
const counter = new Counter({ workspace: 'your-workspace-slug' });

counter.up('your-counter-slug')
  .then(result => {
	// for debugging purposes
	console.log('Counter result:', result);
	console.log(`Visits: ${result.data.up_count}`);
	// update the counter display
	document.getElementById('counter').textContent = result.data.up_count;
  })
  .catch(err => console.error(err));
</script>

<div>visits: <span id="counter"></span></div>