A lightweight, self-hosted web analytics tool built with Next.js and Convex. This tracker provides real-time visitor data, session metrics, and a customizable dashboard with charts and maps.
- Visitor Tracking: Number of visitors per day/week.
- Session Metrics: Bounce rate, session time, conversion rate.
- Live Visitor Count: See how many users are active now.
- Page & Referrer Tracking: See which pages were visited and their referral sources.
- Geolocation Data: Visualize visitor locations on a world map.
- Graphical Reports: Display visitor trends using AG Charts.
- Multi-Site Tracking: Register multiple websites to track analytics.
- Framework: Next.js 15
- Database: Convex
- Frontend Libraries:
- AG Charts (ag-charts-community, ag-charts-react)
- Leaflet & React-Leaflet (for maps)
- Recharts (for data visualization)
- Tailwind CSS for styling
- Radix UI & Lucide React for UI components
- Clone the repository:
git clone https://github.com/your-username/web-analytics.git cd web-analytics - Install dependencies:
npm install
- Set up Convex (refer to Convex documentation for API keys and database setup).
- Ensure you configure allowed origins in
convex/http.ts:const ALLOWED_ORIGINS = [ "http://localhost:3000", "http://localhost:3001", // Add your production domains here ];
- Start the development server:
npm run dev
To track analytics on a website, insert the following script into the <head> section:
<script>
<link rel="preload" href="/analytics-tracker.js" as="script" />;
</script>This will automatically start tracking page views, sessions, and user interactions.
- The analytics dashboard provides an overview of site activity, including real-time visitors, bounce rate, session time, and geographic locations.
- To access the dashboard, navigate to
/dashboardafter running the app locally or deploying it. 
This project is licensed under the MIT License.
Contributions are welcome! If you'd like to improve this project, feel free to fork it and submit a pull request.