Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebTraffic Analytics

A privacy-friendly website analytics platform — a cookieless Google Analytics alternative. Drop a tiny script on your site and watch visitors, sources, pages, sessions and conversions update in real time. No cookies, no consent banner, no personal data stored.

Built with Node.js + Express + MongoDB + WebSocket, an EJS server-rendered "Beacon" dashboard, and Chart.js.

Stack: Node (ESM) · Express · MongoDB (Mongoose) · ws · EJS · Chart.js Port: 5353 · Theme: Beacon (light + dark) · DB default: in-memory MongoDB (zero-config)


Features

  • Real-time dashboard — visitors online now, a live event feed and KPIs (unique visitors, pageviews, sessions, avg. session time, bounce rate, conversion rate) over today / 24h / 7d / 30d.
  • Source analyzer — direct / search / social / referral, as a hover-data doughnut and a top-referrers table.
  • Traffic trend — visitors and pageviews over time with hover tooltips.
  • Top pages, devices, referrers — resizable tables with inline share bars.
  • Conversion tracker — define goals (a custom event or a destination page, prefix match with *) and see conversion rates per goal.
  • Custom event trackingwta('signup', { plan: 'pro' }) for clicks, form submits, anything.
  • Export — one-click CSV and Excel reports.
  • Multi-site — add sites, switch from the top bar, each gets its own snippet.
  • In-app log monitor, dark/light theme, and a collapsible icon-rail sidebar (toggle with the chevron or the [ key).
  • Live demo site at /demo that's wired to the tracker so you can watch events flow in.

Privacy by design (no GDPR consent needed)

  • No cookies, no localStorage on the tracked site.
  • No personal data stored — never an IP address, never a raw user-agent.
  • Visitors are counted with a daily-rotating hash of salt + site + ip + ua. The salt changes every day, so a visitor can't be linked across days. The IP and user-agent are used only in memory to compute that hash and are never written to disk.
  • Do-Not-Track is honoured. No cross-site tracking, no fingerprinting.

This puts it in the same category as Plausible / Fathom — analytics you can run without a consent pop-up. (Technical overview, not legal advice.)


Quick start

Zero-config (in-memory MongoDB)

No database to install. The server boots an in-memory MongoDB (mongodb-memory-server), seeds a demo site with ~30 days of traffic, and starts a live traffic simulator.

npm install
npm start            # → http://localhost:5353

Open the dashboard, then open /demo in another tab and click around — every pageview and event appears live.

With real MongoDB

docker compose up -d                 # MongoDB on :27017
cp .env.example .env                 # set MONGODB_URI=mongodb://localhost:27017/webtraffic
npm install && npm run seed          # optional demo data
npm start

Install the tracker on your own site

From Install, copy your snippet into your page <head>:

<script defer data-site="YOUR_TRACKING_ID" src="http://localhost:5353/track.js"></script>

Track custom events anywhere:

wta('signup', { plan: 'pro' });
button.addEventListener('click', () => wta('cta_click', { id: 'hero' }));

The tracker is ~1 KB, cookieless, honours Do-Not-Track, and handles SPA route changes automatically.


How it fits together

WebTraffic Analytics/
├── server/
│   ├── index.js            # express + ws + mongo + auto-seed + simulator
│   ├── db.js               # mongoose (real MongoDB or in-memory fallback)
│   ├── ws.js               # WebSocket hub (live feed + active count)
│   ├── models/             # Site · Event · Goal · Log
│   ├── lib/
│   │   ├── privacy.js       # daily-salt cookieless visitor hash
│   │   ├── parse.js         # referrer → source, UA → device/browser
│   │   ├── sessions.js      # 30-min session windowing
│   │   └── logger.js
│   ├── services/
│   │   ├── stats.js         # aggregations (KPIs, trend, sources, conversions)
│   │   └── export.js        # CSV + Excel
│   ├── routes/              # collect (tracker) · api (JSON) · pages (EJS)
│   ├── seed.js · simulator.js
├── views/                  # EJS: dashboard, events, conversions, install, logs, privacy, demo
└── public/
    ├── track.js            # the embeddable tracker
    ├── css/app.css         # the Beacon design system
    └── js/                 # app.js, charts.js, dashboard.js + vendored Chart.js

Data model notes

  • One Event per hit; only coarse, non-identifying fields are stored (path, source, device class, browser family, daily visitor hash, session id).
  • Sessions are resolved at collect time (reuse within a 30-minute window).
  • Stats are aggregated on read with MongoDB aggregation pipelines.

API

Method Endpoint Description
POST /api/collect tracker ingestion (cookieless)
GET /track.js the embeddable tracker script
GET /api/stats?site=&range= dashboard aggregates
GET /api/realtime?site= active visitors + recent hits
GET /api/events?site=&type= raw event stream
GET /api/export/csv|excel?site=&range= report download
GET/POST /api/sites list / create sites
POST/DELETE /api/goals manage conversion goals
WS /ws live hit broadcast

License

Apache License 2.0 — see LICENSE.

About

Privacy-friendly, cookieless website analytics — a Google Analytics alternative. Node.js + Express + MongoDB + WebSocket, real-time dashboard, source analyzer, conversion tracker, CSV/Excel export.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages