A lightweight, real-time web analytics tracker built on Val Town. Monitor traffic across multiple sites from a single dashboard—no external dependencies, no monthly bills.
Inspired by Stats and GoatCounter.
Click the fork button to create your own copy.
The tables initialize automatically on first run. If you need to manually set them up, call initAnalytics() from backend/database/migrations.ts.
Edit the counterTownConfig object in backend/lib/CounterTown.ts with your site information and add your site URLs to allowedOrigins.
Place this snippet just before the closing </body> tag on each site you want to track:
<script> (function() { var script = document.createElement('script'); script.async = true; script.src = 'https://<your-username>-<project-name>.val.run/trackingScript'; var firstScript = document.getElementsByTagName('script')[0]; firstScript.parentNode.insertBefore(script, firstScript); })(); </script>
Replace <your-username> and <project-name> with your Val Town username and project name (e.g., https://nbbaier-countertown.val.run/trackingScript).
Navigate to your val's HTTP endpoint to see live analytics.