Real Analytics Tracker (RAT) - A privacy-focused, lightweight analytics platform that puts user privacy first while providing powerful insights for website owners.
RAT is a self-hosted, open-source analytics solution designed for developers and businesses who value user privacy. Unlike traditional analytics platforms, RAT collects only essential data without cookies or invasive tracking, ensuring compliance with privacy regulations like GDPR and CCPA.
- π Privacy-First: No cookies, no personal identifiers, no cross-site tracking
- π Project-Based Analytics: Organize your analytics by projects with granular access control
- π₯ Multi-User Support: Admin and viewer roles with secure authentication
- π Project Sharing: Share analytics access with team members or clients
- β‘ Lightweight: Minimal JavaScript snippet that doesn't impact page performance
- π³ Easy Deployment: Docker-ready with SQLite database (no external dependencies)
- π± Responsive Dashboard: Clean, modern interface for viewing analytics
- π Secure: Password hashing, session management, and role-based access control
RAT Analytics is committed to transparency and legal compliance:
- MIT License: Open-source software license
- Terms and Conditions: Service usage terms
- Privacy Policy: Data collection and privacy practices
- GDPR Compliant: Designed to comply with EU data protection regulations
- CCPA Compliant: California Consumer Privacy Act compliance
- Self-Hosted: You control your data and compliance requirements
Deploy RAT on your own infrastructure with complete control:
git clone https://github.com/wenesay/rat.git
cd rat
docker-compose up -dgit clone https://github.com/wenesay/rat.git
cd rat
npm install
npm startAccess your dashboard at http://localhost:3000
Default credentials: admin / admin (change immediately!)
Prefer zero setup and maintenance? Join the waitlist for RAT Analytics Managed - coming soon with:
- βοΈ Zero Setup: Start tracking in minutes
- π Automatic Updates: We handle maintenance
- π‘ Focus on Insights: Let us manage infrastructure
Both options provide the same privacy-first analytics. Choose based on your preference for control vs. convenience.
- Features
- Legal & Compliance
- Quick Start
- Hosting Options
- Configuration
- Usage
- API Documentation
- Deployment Guide
- Contributing
- License
- Support
- Node.js 14+ and npm
- Docker and Docker Compose (optional, for containerized deployment)
-
Clone the repository
git clone https://github.com/wenesay/rat.git cd rat -
Install dependencies
npm install
-
Configure environment (optional)
cp .env.example .env # Edit .env with your settings -
Start the server
npm start
-
Access the dashboard
- Open
http://localhost:3000in your browser - Register a new account or login with existing credentials
- Open
git clone https://github.com/wenesay/rat.git
cd rat
docker-compose up -dAccess at http://localhost:3000
Create a .env file in the root directory:
# Server Configuration
PORT=3000
NODE_ENV=production
# Security (Required)
SESSION_SECRET=your-super-secure-random-session-secret-here
# Database
DATABASE_PATH=./analytics.db
# CORS (optional)
ALLOWED_ORIGINS=https://yourdomain.com
# Admin Setup (only for initial setup)
SETUP_ADMIN=true
DEFAULT_ADMIN_USERNAME=admin
DEFAULT_ADMIN_PASSWORD=SecurePassword123!Security Note: Generate a secure session secret with: openssl rand -base64 32
- Password Hashing: bcrypt with salt rounds
- Session Management: Secure HTTP-only cookies
- Rate Limiting: Prevents abuse of endpoints
- Input Validation: Sanitizes all user inputs
- CORS Protection: Configurable origin restrictions
- Helmet Security Headers: XSS and clickjacking protection
# Build and run with Docker Compose
git clone https://github.com/wenesay/rat.git
cd rat
docker-compose up -d# Install dependencies
npm install
# Start production server
npm startRAT can be deployed to any platform supporting Node.js:
- Railway: Connect GitHub repo, automatic deployments
- Render: Deploy from GitHub with persistent disks
- Fly.io: Use included Dockerfile and fly.toml
- Vercel: Serverless deployment (requires modifications)
- Heroku: Traditional deployment with buildpacks
For production deployment, ensure these environment variables are set:
NODE_ENV=production
SESSION_SECRET=your-secure-secret-here
PORT=3000- Use HTTPS (required for secure cookies)
- Set strong
SESSION_SECRET - Configure
ALLOWED_ORIGINSfor CORS - Use environment variables, never commit secrets
- Regularly update dependencies
- Monitor logs and set up alerts
- DigitalOcean App Platform: Docker-based deployment
- Heroku: Traditional PaaS (consider migration)
- AWS: EC2 + RDS, Lightsail for simple setups
- Google Cloud: App Engine, Cloud Run
- Azure: App Service, Container Instances
- SQLite: Default, file-based (perfect for single instances)
- PostgreSQL: Production recommended
- MySQL: Enterprise environments
# Use external PostgreSQL
export DATABASE_URL=postgresql://user:pass@host:5432/rat_db
npm startTry before you deploy:
cd demo
docker-compose -f docker-compose.demo.yml up -dAccess at http://localhost:3000 with pre-populated demo data.
Create a .env file in the root directory with the following variables:
# Required
SESSION_SECRET=your-super-secure-random-session-secret-here
# Optional
PORT=3000
NODE_ENV=production
ALLOWED_ORIGINS=https://yourdomain.com
DATABASE_PATH=./analytics.db
# Admin Setup (only for initial setup)
SETUP_ADMIN=true
DEFAULT_ADMIN_USERNAME=admin
DEFAULT_ADMIN_PASSWORD=SecurePassword123!Security Note: Never commit your .env file to version control. Use the provided .env.example as a template.
- Copy
.env.exampleto.env - Generate a secure session secret:
openssl rand -base64 32 - Set a strong admin password
- Run the application
The admin user will be created automatically on first run if SETUP_ADMIN=true.
- Use HTTPS in production
- Change default admin credentials immediately
- Use strong, unique passwords
- Regularly update dependencies
- Monitor logs for suspicious activity
First, deploy RAT on your own server (see Quick Start above).
- Access your RAT dashboard at
http://your-server.com - Register a new account or login with existing credentials
- Default credentials:
admin/admin(change immediately!)
- Navigate to the Projects section in your dashboard
- Click "Create New Project"
- Give your project a name (e.g., "My Website Analytics")
- In your project dashboard, click "Get Code" or "Tracking Code"
- Copy the provided HTML snippet
Include the tracking code in the <head> section of your website:
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<!-- RAT Analytics Tracking Code -->
<script>
window.ratAnalyticsProjectId = 'your-project-id-here';
</script>
<script src="https://your-rat-server.com/snippet/analytics.js"></script>
</head>
<body>
<!-- Your website content -->
</body>
</html>Replace:
your-project-id-herewith your actual project IDhttps://your-rat-server.comwith your RAT server URL
Track custom events beyond automatic page views:
// Track custom events (if implemented)
if (window.ratAnalytics) {
window.ratAnalytics.track('button_click', {
button_id: 'cta_main',
page: window.location.pathname
});
}Identify users without collecting personal data:
// Set anonymous user identifier (if implemented)
if (window.ratAnalytics) {
window.ratAnalytics.identify('anonymous_user_123');
}- Real-time Metrics: Total views, unique visitors, sessions
- Top Pages: Most visited pages on your site
- Traffic Sources: Referrer analysis
- Device & Browser Stats: Technical breakdown
- Multiple Projects: Track different websites or sections
- Access Control: Share projects with team members
- API Keys: Generate project-specific tracking keys
- Role-Based Access: Admin and viewer roles
- Team Collaboration: Invite users to projects
- Secure Authentication: Password-protected access
RAT is designed with privacy as the foundation:
- Page URL: Current page path (anonymized)
- Referrer: Source website (if available)
- Timestamp: When the visit occurred
- Technical Data: Browser type, screen size, device type
- Session Data: Temporary session identifier (not stored long-term)
- Personal Information: No names, emails, or identifiers
- Cookies: No tracking cookies or local storage
- IP Addresses: Not stored (privacy protection)
- User Behavior: No mouse tracking or heatmaps
- Third-Party Data: No integration with other tracking services
- GDPR Compliant: Minimal data collection, no personal data
- CCPA Compliant: No sale of personal information
- Self-Hosted: You control all your data
- Data Retention: Configurable retention policies
POST /login- User authenticationPOST /logout- User logoutGET /api/user- Get current user infoPOST /register- User registration
POST /track- Record page view (public, requires projectId)GET /api/stats/:projectId- Get project analytics
GET /api/projects- List user's projectsPOST /api/projects- Create new projectGET /api/users- List users (admin only)POST /api/users- Create user (admin only)
GET /snippet/analytics.js- Analytics tracking scriptGET /- Dashboard (requires authentication)GET /login.html- Login pageGET /register.html- Registration page
RAT includes built-in SEO optimizations:
- Meta Tags: Proper Open Graph and Twitter Card support
- Sitemap: Auto-generated sitemap.xml for search engines
- Robots.txt: Search engine crawling instructions
- Structured Data: JSON-LD for better search understanding
- Advanced analytics visualizations
- Custom dashboard themes
- API rate limiting improvements
- Enhanced security features
- Plugin system for custom analytics
- Export functionality improvements
git clone https://github.com/wenesay/rat.git
cd rat
npm install
npm run devnpm test
npm run lintThis project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation
- π Bug Reports
- π¬ Discussions
- Built with Express.js
- Database powered by SQLite
- Authentication via express-session
git clone https://github.com/wenesay/rat.git
cd rat
npm install && npm startMade with β€οΈ by the RAT Analytics Team
β Star this repo if you find it useful!
- Privacy-First: Only collects essential data (URL, referrer, user agent) without cookies or personal identifiers
- Project-Based: Organize analytics by projects with granular access control
- User Management: Admin users can create accounts and manage permissions
- Sharing: Share projects with other users as viewers or admins
- Lightweight: Minimal JavaScript snippet that doesn't block page loading
- Easy Hosting: Simple Node.js application with SQLite database
- Minimal Dashboard: Clean, tabbed interface for viewing analytics and managing projects/users
-
Clone the repository:
git clone https://github.com/wenesay/rat.git cd rat -
Run with Docker Compose:
docker-compose up -d
The server will run on http://localhost:3000.
-
Clone the repository:
git clone https://github.com/wenesay/rat.git cd rat -
Install dependencies:
npm install
-
Start the server:
npm start
The server will run on http://localhost:3000.
-
Create a Project: Log into your dashboard and create a new project to get a Project ID.
-
Add the Snippet: Include the analytics script on your website with your project ID:
Option 1: Global Variable
<script> window.ratAnalyticsProjectId = 'YOUR_PROJECT_ID'; </script> <script src="https://your-domain.com/snippet/analytics.js"></script>
Option 2: Meta Tag
<meta name="rat-analytics-project" content="YOUR_PROJECT_ID"> <script src="https://your-domain.com/snippet/analytics.js"></script>
Important: Before deploying, edit snippet/analytics.js and replace your-analytics-server.com with your actual domain.
- URL: The current page URL
- Referrer: The referring page (if available)
- User Agent: Browser information (for technical analysis)
- Timestamp: When the page view occurred
No personal data, cookies, or tracking identifiers are collected.
GET /snippet/analytics.js- Serves the analytics snippetPOST /track- Receives analytics data (requires projectId)
GET /login- Login pagePOST /login- Authenticate userPOST /logout- Logout user
GET /api/user- Get current user infoGET /api/projects- List user's accessible projectsPOST /api/projects- Create new projectPOST /api/projects/:id/share- Share project with userGET /api/stats/:projectId- Get analytics for specific projectGET /api/users- List all users (admin only)POST /api/users- Create new user (admin only)PUT /api/users/:id/password- Change user password
Visit http://your-domain.com to view your analytics dashboard, which shows:
- Total page views
- Number of unique pages
- Top viewed pages
Build and run the Docker container:
docker build -t rat-analytics .
docker run -p 3000:3000 -v $(pwd)/analytics.db:/app/analytics.db rat-analyticsThis application can be deployed to any platform that supports Node.js:
- Heroku: Push to Heroku with
git push heroku main - Vercel: Use Vercel's Node.js runtime
- Railway: Connect your GitHub repo
- Render: Deploy from GitHub
- Fly.io: Use the Dockerfile
PORT: Server port (default: 3000)
- Admin: Full access to create projects, manage users, view all analytics
- Viewer: Can view analytics for assigned projects only
- Self-Registration: Users can register accounts through
/register.html - Secure Login: Session-based authentication with secure cookies
- Password Security: bcrypt hashing with salt rounds
- Session Management: Automatic logout on inactivity
Admin users can:
- Create and manage user accounts
- View all projects and analytics
- Access user management dashboard
- Change their own password and profile
On first run, if SETUP_ADMIN=true in environment:
- Creates default admin user
- Allows initial configuration
- Should be disabled after setup
Important: Change default credentials immediately!
By default, uses SQLite (analytics.db). To use a different database:
- Modify
server.jsto connect to your preferred database - Update the schema creation and queries accordingly
Set the PORT environment variable to change the default port (3000).
npm testnpm run dev- Password Hashing: bcrypt with configurable salt rounds
- Session Security: HTTP-only, secure cookies with configurable settings
- Rate Limiting: Prevents brute force and abuse
- Input Validation: Comprehensive validation and sanitization
- CORS Protection: Configurable allowed origins
- Security Headers: Helmet.js provides XSS and clickjacking protection
- CSRF Protection: Token-based CSRF prevention
- SQL Injection Prevention: Parameterized queries
- β Use HTTPS in production
- β
Set strong, unique
SESSION_SECRET - β
Configure
ALLOWED_ORIGINSappropriately - β Use environment variables for all secrets
- β Regularly update dependencies
- β Monitor logs for suspicious activity
- β Enable rate limiting
- β Use strong passwords
- β Keep backups of the database
RAT is designed to be privacy-compliant:
- GDPR/CCPA Ready: Minimal data collection, no personal identifiers
- No Cookies: No tracking cookies or local storage
- Data Control: Self-hosted means you control all data
- Transparency: Open source code for audit
- User Consent: Respects Do Not Track headers
This analytics tool is designed with privacy in mind:
- No cookies or local storage
- No cross-site tracking
- Data is stored locally on your server
- Only aggregate statistics are displayed
- Easy to audit and self-host
MIT License - see LICENSE file for details.
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
For questions or issues, please open an issue on GitHub.