A modern, privacy-focused web analytics platform built for developers and teams. Track website visitors in real-time without cookies, fully GDPR-compliant.
Trackly is a lightweight, open-source web analytics platform that helps you understand your users without compromising their privacy. Unlike traditional analytics tools that rely on cookies and invasive tracking, Trackly provides meaningful insights while respecting user privacy.
- π΄ Real-time Analytics - See live visitors on your site as they browse
- πͺ Cookie-free Tracking - No cookies, no consent banners needed
- π‘οΈ GDPR Compliant - Privacy-first approach, no personal data collection
- π Beautiful Dashboard - Clean, modern UI to visualize your data
- β‘ Lightweight Script - Tiny tracking script (~2KB) that won't slow your site
- π Geo-location Insights - See where your visitors come from (country, region, city)
- π± Device Analytics - Track browsers, operating systems, and devices
- π Referrer Tracking - Know where your traffic originates
- π UTM Campaign Support - Track marketing campaigns with UTM parameters
- β±οΈ Session Duration - Measure how long visitors spend on your site --
You can Use the Trackly from : https://trackly-beta.vercel.app
- Free For All
- Easy Google Authntication
- Node.js 18+
- PostgreSQL database (we recommend Neon for serverless)
- Google OAuth credentials (for authentication)
-
Clone the repository
git clone https://github.com/yourusername/trackly.git cd trackly -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory:# Database DATABASE_URL=your_postgresql_connection_string # Authentication (Better Auth) BETTER_AUTH_SECRET=your_secret_key_here BETTER_AUTH_URL=http://localhost:3000 # Google OAuth GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret # App URL NEXT_PUBLIC_APP_URL=http://localhost:3000
-
Push database schema
npm run db:push
-
Start the development server
npm run dev
-
Open http://localhost:3000 in your browser
Sign up using your Google account or email to access the dashboard.
- Navigate to the Dashboard
- Click "Add Website"
- Enter your website domain and timezone
- Copy the generated tracking script
Add the tracking script to your website's <head> section:
<script
defer
data-website-id="your-website-id"
data-domain="https://your-domain.com"
src="https://your-trackly-instance.com/analytics.js">
</script>Once the script is installed, you'll start seeing data in your dashboard:
- Visitors - Unique visitors count
- Page Views - Total page views
- Live Users - Real-time active users
- Active Time - Total and average session duration
- Traffic Sources - Referrers and UTM campaigns
- Geography - Visitor locations on a map
- Devices - Browser, OS, and device breakdown
| Category | Technology |
|---|---|
| Framework | Next.js 15 (App Router) |
| Language | TypeScript |
| Database | PostgreSQL with Neon |
| ORM | Drizzle ORM |
| Authentication | Better Auth |
| Styling | Tailwind CSS |
| UI Components | shadcn/ui + Radix UI |
| Charts | Recharts |
| HTTP Client | Axios |
| Date Handling | date-fns |
| Icons | Lucide React |
| Deployment | Vercel |
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Your Website ββββββΆβ Trackly API ββββββΆβ PostgreSQL β
β (analytics.js) β β (Next.js API) β β (Neon DB) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Dashboard β
β (React/Next) β
ββββββββββββββββββββ
-
Page Entry: When a visitor lands on your site, the
analytics.jsscript:- Generates a unique visitor ID (stored in localStorage, not cookies)
- Captures entry time, referrer, URL, and UTM parameters
- Sends a POST request to
/api/trackwith visitor data
-
Server Processing: The tracking API endpoint:
- Parses the user-agent for device/browser/OS info
- Fetches geo-location data from the visitor's IP
- Stores the pageview in the
pageViewstable
-
Live Tracking: While browsing:
- The script sends heartbeat pings every 10 seconds to
/api/live - This enables real-time "live users" count on your dashboard
- The script sends heartbeat pings every 10 seconds to
-
Page Exit: When the visitor leaves:
- The
beforeunloadevent triggers an exit tracking call - Records exit time and total active time spent
- Updates the session record in the database
- The
The main tables include:
user- User accounts (Better Auth managed)session- Authentication sessionswebsites- Registered websites for trackingpageViews- Individual page view events with full analytics dataliveUser- Currently active visitors (updated in real-time)
- No cookies - Visitor IDs stored in localStorage only
- No fingerprinting - No canvas, WebGL, or other fingerprinting techniques
- IP anonymization - IP addresses used only for geo-lookup, then discarded
- Session isolation - 12-hour session windows, then new visitor ID generated
- Minimal data - Only essential analytics data collected
trackly/
βββ app/ # Next.js App Router
β βββ api/ # API Routes
β β βββ track/ # Pageview tracking endpoint
β β βββ live/ # Live user heartbeat endpoint
β β βββ website/ # Website CRUD operations
β β βββ auth/ # Better Auth handlers
β βββ dashboard/ # Dashboard pages
β βββ login/ # Authentication pages
β βββ signup/
βββ components/ # React components
β βββ ui/ # shadcn/ui components
β βββ ... # Feature components
βββ lib/ # Utilities and configurations
β βββ auth.ts # Better Auth setup
β βββ utils.ts # Helper functions
βββ src/DB/ # Database
β βββ index.ts # Drizzle client
β βββ schema.ts # Database schema
βββ public/
β βββ analytics.js # Client tracking script
βββ drizzle.config.ts # Drizzle Kit configuration
# Run development server
npm run dev
# Run linting
npm run lint
# Push schema changes to database
npm run db:push
# Open Drizzle Studio (database GUI)
npm run db:studio
# Build for production
npm run build
# Start production server
npm run start- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy!
The app is optimized for Vercel's Edge Network with serverless functions.
MIT License - feel free to use this project for personal or commercial purposes.
-Contributions are welcome! Please feel free to submit a Pull Request.
-For any queries reach me out at arvindchoudhary054@gmail.com
Built with β€οΈ By Arvind Choudhary