100% GDPR Compliant By Design

Privacy-First Analytics

A lightweight, high-performance middleware for tracking views and events without compromising user privacy. Self-hosted, secure, and ready for production.

API Reference Fork on GitHub

Why ViewCounter?

Designed for speed, security, and simplicity.

🚀 Built-in Performance

Powered by MySQL2 with connection pooling, optimized for concurrent high-traffic apps.

🛡️ Production Ready

Full security hardening with Helmet, Rate-limiting, and SQL injection prevention via prepared statements.

📊 Rich Insights

Track page paths, titles, traffic sources, and browsers. Now supporting both Total Views and Unique Visitors.

Trust & Transparency

We believe in "Show, Don't Tell". Here is the exact lifecycle of a request.

🌍

Request

Raw IP + UserAgent

⚙️

Processing

IP masked to .0
Salted Hashing

🗑️

Discarded

Raw IP deleted from memory

💾

Storage

Masked IP + Hash
Saved to DB

🍪 Zero Cookies

No Set-Cookie headers, no localStorage, and no "Cookie Consent" banners needed.

🆔 Transient Hashing

We replace your IP with a SHA256 hash salted daily. We track "Unique Views" without ever storing your real identity.

🏠 Data Ownership

Self-hosted data. Your analytics never leave your infrastructure or get shared with big tech.

🤏 IP Masking

We only use your IP for initial Country lookup, then immediately mask it (e.g. 1.2.3.0) before storage.

✅ Automated Guardrails

Our build pipeline includes Fail-Safe Tests that scan database queries to ensure raw IPs never leak into storage.

Quick Start

Get up and running in under 60 seconds.

1. Installation

git clone https://github.com/harshankur/viewcounter.git
npm install

2. Setup

npm run setup

3. Launch

npm start

API Specification

Explore the endpoints and response formats.

Debugging & Tips

Check Server Readiness

Use the /health endpoint to verify server and database connectivity. If returns 503, check your database credentials in dbInfo.json.


Testing with Mocks

Run npm test to execute 60+ tests using our custom mocking system. No real database required!


View Persistent Data

Run PERSIST_TEST_DB=true npm test to keep the test database for inspection.