A lightweight, self-hosted web analytics platform: add one script tag to any website, collect page views, and view multi-site insights in a dashboard. Built with Next.js (App Router) + Supabase.
Goal: simple, hackable, OSS-friendly analytics you can run on your own domain.
This one Next.js project does three things:
- Serves the tracking script
- URL:
https://YOUR-ANALYTICS-DOMAIN/track.js - You paste this into other websites using a
<script>tag.
- Receives pageview events
- URL:
https://YOUR-ANALYTICS-DOMAIN/api/track - The tracking script sends pageview data here.
- Shows a dashboard
- URL:
https://YOUR-ANALYTICS-DOMAIN/dashboard - Displays analytics for one site or all sites.
If you are using Next.js App Router, these are the important files:
-
Tracking script (the JS file served to the public):
app/track.js/route.ts
-
Tracking API endpoint (receives POST requests and inserts into Supabase):
app/api/track/route.ts
-
Sites API endpoint (lists sites shown in the dashboard selector):
app/api/sites/route.ts
-
Analytics API endpoint (aggregates analytics for dashboard):
app/api/analytics/route.ts
-
Dashboard UI page:
app/dashboard/page.tsx
- Node.js 18+
- A Supabase project (Postgres)
git clone <your-repo-url>
cd web-analytics
npm install