Skip to content

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.

Notifications You must be signed in to change notification settings

Ledjob/Web-Analytics-Tracker

Repository files navigation

Web Analytics Tracker

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.

Features

  • 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.

Tech Stack

  • 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

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/web-analytics.git
    cd web-analytics
  2. Install dependencies:
    npm install
  3. Set up Convex (refer to Convex documentation for API keys and database setup).
  4. Ensure you configure allowed origins in convex/http.ts:
    const ALLOWED_ORIGINS = [
      "http://localhost:3000",
      "http://localhost:3001",
      // Add your production domains here
    ];
  5. Start the development server:
    npm run dev

Usage

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.

Dashboard

  • 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 /dashboard after running the app locally or deploying it.
  • Alt text

License

This project is licensed under the MIT License.

Contributions

Contributions are welcome! If you'd like to improve this project, feel free to fork it and submit a pull request.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published