Deploying Ackee
Introduction
Ackee is a self-hosted, privacy-focused web analytics tool that provides valuable insights into your website’s traffic while respecting user privacy. Unlike traditional analytics platforms, Ackee doesn’t use cookies, doesn’t track users across sites, and is fully GDPR-compliant out of the box. Built with Node.js and MongoDB, Ackee offers a clean, modern interface with real-time analytics tracking.
Ackee stands out for its:
- Privacy-First Approach: No cookies, no persistent tracking, and full GDPR compliance
- Self-Hosted Control: Complete ownership of your analytics data
- Real-Time Insights: Live visitor tracking and instant metrics
- Beautiful Interface: Clean, modern dashboard with intuitive data visualization
- Lightweight: Minimal resource usage with efficient data storage
- GraphQL API: Flexible data access for custom integrations
- Multiple Domain Support: Track analytics for multiple websites from a single instance
This comprehensive guide walks you through deploying Ackee analytics on Klutch.sh using Docker, including detailed installation steps, sample configurations, persistent storage setup, and production-ready best practices.
Prerequisites
Before you begin, ensure you have the following:
- A Klutch.sh account
- A GitHub account with a repository for your Ackee project
- Docker installed locally for testing (optional but recommended)
- Basic understanding of Docker and web analytics concepts
Installation and Setup
Step 1: Create Your Project Directory
First, create a new directory for your Ackee deployment project:
mkdir ackee-klutchcd ackee-klutchgit initStep 2: Create the Dockerfile
Create a Dockerfile in your project root directory. This will define your Ackee container configuration:
FROM node:18-alpine
# Set working directoryWORKDIR /app
# Install Ackee globallyRUN npm install -g ackee
# Create data directory for MongoDBRUN mkdir -p /data/db
# Expose the default Ackee portEXPOSE 3000
# Set default environment variablesENV ACKEE_MONGODB=mongodb://localhost:27017/ackeeENV ACKEE_USERNAME=adminENV ACKEE_PASSWORD=password
# Start MongoDB and AckeeCMD mongod --fork --logpath /var/log/mongodb.log && ackee serverNote: This Dockerfile uses Node.js Alpine image for a lightweight production deployment. For a more robust setup with a separate MongoDB instance, see the advanced configuration section below.
Step 3: Advanced Dockerfile with MongoDB
For a production-ready setup with MongoDB included in the same container:
FROM node:18-alpine
# Install MongoDBRUN apk add --no-cache mongodb mongodb-tools
# Set working directoryWORKDIR /app
# Install AckeeRUN npm install -g ackee@3.4.0
# Create necessary directoriesRUN mkdir -p /data/db /var/log
# Expose Ackee portEXPOSE 3000
# Set environment variables (override these in Klutch.sh dashboard)ENV ACKEE_MONGODB=mongodb://localhost:27017/ackeeENV ACKEE_USERNAME=adminENV ACKEE_PASSWORD=changemeENV NODE_ENV=production
# Create startup scriptRUN echo '#!/bin/sh' > /start.sh && \ echo 'mongod --bind_ip 127.0.0.1 --fork --logpath /var/log/mongodb.log' >> /start.sh && \ echo 'sleep 3' >> /start.sh && \ echo 'ackee server' >> /start.sh && \ chmod +x /start.sh
# Start servicesCMD ["/start.sh"]Step 4: Create Environment Configuration
Create a .env.example file to document the required environment variables:
# Ackee ConfigurationACKEE_MONGODB=mongodb://localhost:27017/ackeeACKEE_USERNAME=adminACKEE_PASSWORD=your-secure-password-here
# Optional: Custom port (default is 3000)ACKEE_PORT=3000
# Optional: CORS settings for tracking scriptACKEE_ALLOW_ORIGIN=*
# Optional: Auto SSLACKEE_AUTO_SSL=falseSecurity Note: Never commit actual passwords or sensitive data to your repository. Use environment variables in Klutch.sh dashboard.
Step 5: Test Locally (Optional)
Before deploying to Klutch.sh, you can test your Ackee setup locally:
# Build the Docker imagedocker build -t my-ackee .
# Run the containerdocker run -d \ --name ackee-test \ -p 3000:3000 \ -e ACKEE_USERNAME=admin \ -e ACKEE_PASSWORD=test123 \ my-ackee
# View logsdocker logs -f ackee-test
# Access Ackee at http://localhost:3000
# Stop and remove the test container when donedocker stop ackee-testdocker rm ackee-testStep 6: Create Sample Tracking Script Documentation
Create a README.md file with tracking script instructions:
# Ackee Analytics Deployment
## Adding Tracking to Your Website
Once Ackee is deployed, add this script to your website's HTML:
<script async src="https://example-app.klutch.sh/tracker.js" data-ackee-server="https://example-app.klutch.sh" data-ackee-domain-id="YOUR_DOMAIN_ID"></script>
Replace:- `example-app.klutch.sh` with your actual Klutch.sh app URL- `YOUR_DOMAIN_ID` with the domain ID from your Ackee dashboard
## Getting Your Domain ID
1. Log in to Ackee at your deployment URL2. Go to Settings > Domains3. Create a new domain or copy the ID of an existing one4. Use this ID in your tracking scriptStep 7: Push to GitHub
Commit your Dockerfile and configuration files to your GitHub repository:
git add Dockerfile .env.example README.mdgit commit -m "Add Ackee Dockerfile and configuration"git remote add origin https://github.com/yourusername/ackee-klutch.gitgit push -u origin mainDeploying to Klutch.sh
Now that your Ackee project is ready and pushed to GitHub, follow these steps to deploy it on Klutch.sh with persistent storage.
Deployment Steps
-
Log in to Klutch.sh
Navigate to klutch.sh/app and sign in to your account.
-
Create a New Project
Go to Create Project and give your project a meaningful name (e.g., “Ackee Analytics”).
-
Create a New App
Navigate to Create App and configure the following settings:
-
Select Your Repository
- Choose GitHub as your Git source
- Select the repository containing your Dockerfile
- Choose the branch you want to deploy (usually
mainormaster)
-
Configure Traffic Type
- Traffic Type: Select HTTP (Ackee serves a web interface and tracking script via HTTP)
- Internal Port: Set to
3000(the default port that Ackee listens on)
-
Set Environment Variables
Add the following environment variables for your Ackee configuration:
ACKEE_USERNAME: Your Ackee admin username (e.g.,admin)ACKEE_PASSWORD: A strong password for your admin account (use a secure password generator)ACKEE_MONGODB: MongoDB connection string (e.g.,mongodb://localhost:27017/ackee)ACKEE_PORT: (Optional) Port number, defaults to3000ACKEE_ALLOW_ORIGIN: (Optional) Set to*for tracking from any domain, or specify your domain
Security Note: Always use strong, unique passwords for production deployments.
-
Attach a Persistent Volume
This is critical for ensuring your MongoDB database data persists across deployments and restarts:
- In the Volumes section, click “Add Volume”
- Mount Path: Enter
/data/db(this is where MongoDB stores its database files) - Size: Choose an appropriate size based on your expected traffic (e.g., 5GB for small sites, 20GB+ for high-traffic sites)
Important: Ackee requires persistent storage to maintain your analytics data between container restarts.
-
Configure Additional Settings
- Region: Select the region closest to your users for optimal latency
- Compute Resources: Choose CPU and memory based on your traffic (minimum 512MB RAM recommended)
- Instances: Start with 1 instance (you can scale up later as traffic grows)
-
Deploy Your Application
Click “Create” to start the deployment. Klutch.sh will:
- Automatically detect your Dockerfile in the repository root
- Build the Docker image
- Attach the persistent volume
- Start your Ackee container
- Assign a URL for external access
-
Access Your Ackee Dashboard
Once deployment is complete, you’ll receive a URL like
example-app.klutch.sh. Navigate to this URL in your browser to access your Ackee dashboard:https://example-app.klutch.shLog in using the username and password you set in the environment variables.
Configuring Domains and Tracking
After your Ackee instance is deployed, you need to set up domains for tracking:
Adding a Domain
- Log in to your Ackee dashboard at
https://example-app.klutch.sh - Navigate to Settings → Domains
- Click “New Domain”
- Enter your website’s domain name (e.g.,
mywebsite.com) - Copy the generated Domain ID (you’ll need this for the tracking script)
Installing the Tracking Script
Add the following script to your website’s HTML, just before the closing </body> tag:
<script async src="https://example-app.klutch.sh/tracker.js" data-ackee-server="https://example-app.klutch.sh" data-ackee-domain-id="YOUR_DOMAIN_ID"></script>Replace:
example-app.klutch.shwith your actual Klutch.sh app URLYOUR_DOMAIN_IDwith the domain ID from your Ackee dashboard
Tracking Options
Ackee’s tracking script supports several attributes for customization:
<script async src="https://example-app.klutch.sh/tracker.js" data-ackee-server="https://example-app.klutch.sh" data-ackee-domain-id="YOUR_DOMAIN_ID" data-ackee-opts='{"ignoreLocalhost": true, "detailed": false}'></script>Available options:
ignoreLocalhost: Don’t track visits from localhost (default: true)detailed: Record detailed information like screen size and browser (default: false)ignoreOwnVisits: Ignore visits when logged into Ackee (default: false)
Environment Variables Reference
Complete list of Ackee environment variables you can configure in Klutch.sh:
| Variable | Description | Required | Default |
|---|---|---|---|
ACKEE_MONGODB | MongoDB connection string | Yes | mongodb://localhost:27017/ackee |
ACKEE_USERNAME | Admin username for Ackee dashboard | Yes | None |
ACKEE_PASSWORD | Admin password for Ackee dashboard | Yes | None |
ACKEE_PORT | Port for Ackee server | No | 3000 |
ACKEE_ALLOW_ORIGIN | CORS origin for tracking script | No | * |
ACKEE_AUTO_SSL | Enable automatic SSL (not needed on Klutch.sh) | No | false |
ACKEE_TRACKER | Custom tracker script filename | No | tracker.js |
NODE_ENV | Node environment | No | production |
Using an External MongoDB Database
For production deployments with higher traffic, you may want to use an external MongoDB instance instead of the built-in one. Here’s how:
Option 1: Deploy MongoDB Separately on Klutch.sh
- Follow the MongoDB deployment guide to create a separate MongoDB instance
- Use a simplified Dockerfile for Ackee only:
FROM node:18-alpine
WORKDIR /app
# Install AckeeRUN npm install -g ackee@3.4.0
# Expose Ackee portEXPOSE 3000
ENV NODE_ENV=production
# Start AckeeCMD ["ackee", "server"]- Set the
ACKEE_MONGODBenvironment variable to your MongoDB connection string:ACKEE_MONGODB=mongodb://username:password@mongodb-app.klutch.sh:8000/ackee
Option 2: Use MongoDB Atlas
- Create a free MongoDB Atlas cluster at mongodb.com
- Get your connection string from Atlas
- Set the
ACKEE_MONGODBenvironment variable to your Atlas connection string:ACKEE_MONGODB=mongodb+srv://username:password@cluster.mongodb.net/ackee
Production Best Practices
Security Recommendations
- Strong Passwords: Use a password manager to generate strong, random passwords for
ACKEE_PASSWORD - Environment Variables: Store all sensitive credentials as environment variables in Klutch.sh, never in your Dockerfile
- HTTPS Only: Klutch.sh provides HTTPS by default; ensure you access Ackee only via HTTPS
- Regular Backups: Implement a backup strategy for your MongoDB data using volume snapshots or database exports
- Update Regularly: Keep Ackee updated to the latest version for security patches and new features
- Restrict CORS: In production, set
ACKEE_ALLOW_ORIGINto your specific domain instead of*
Performance Optimization
- Database Indexing: MongoDB automatically creates indexes, but monitor query performance
- Data Retention: Configure Ackee to automatically clean up old data to manage database size
- Caching: Ackee includes built-in caching; ensure it’s enabled for optimal performance
- Resource Allocation: Monitor your application and increase compute resources if response times slow down
- CDN Integration: Consider using a CDN for the tracking script to improve loading times globally
Monitoring and Maintenance
Monitor your Ackee deployment for:
- Response Times: Ensure the dashboard loads quickly and tracking script responds promptly
- Database Size: Watch for unexpected growth in MongoDB storage
- Memory Usage: Ackee should use minimal memory, but monitor for memory leaks
- Tracking Errors: Check logs for any tracking script errors
- Uptime: Use external monitoring services to alert you if Ackee goes down
Data Management
- Regular Exports: Periodically export your analytics data for long-term archival
- Database Backups: Create regular backups of your MongoDB volume
- Data Cleanup: Configure retention policies to remove old data and control database growth
- Analytics Review: Regularly review your analytics to ensure tracking is working correctly
Accessing Analytics via API
Ackee provides a GraphQL API for programmatic access to your analytics data. This is useful for custom dashboards, reporting, and integrations.
Authentication
First, obtain an authentication token:
curl -X POST https://example-app.klutch.sh/api \ -H "Content-Type: application/json" \ -d '{"query":"mutation {createToken(input:{username:\"admin\",password:\"your-password\"}) {payload {id}}}"}'Example Query
Once you have a token, you can query analytics data:
curl -X POST https://example-app.klutch.sh/api \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{"query":"query {domains {id title}}"}'GraphQL Playground
Access the GraphQL playground at:
https://example-app.klutch.sh/apiTroubleshooting
Cannot Access Ackee Dashboard
- Verify your app is running in the Klutch.sh dashboard
- Check that the internal port is set to 3000
- Ensure HTTP traffic type is selected
- Review application logs for startup errors
Tracking Script Not Working
- Verify the domain is added in Ackee settings
- Check that the Domain ID is correct in your tracking script
- Ensure
ACKEE_ALLOW_ORIGINallows your website’s domain - Test the tracking script URL directly in your browser
MongoDB Connection Errors
- Verify the persistent volume is correctly attached at
/data/db - Check MongoDB is starting correctly in the logs
- Ensure sufficient disk space is allocated to the volume
- Verify the
ACKEE_MONGODBconnection string format
Data Not Persisting
- Confirm the persistent volume is attached at
/data/db - Check the volume has sufficient space
- Verify MongoDB is writing to the correct directory
Performance Issues
- Monitor CPU and memory usage in Klutch.sh dashboard
- Consider increasing compute resources
- Check MongoDB queries aren’t blocking the application
- Review analytics data size and implement retention policies
Upgrading Ackee
To upgrade Ackee to a new version:
-
Update the version in your Dockerfile:
RUN npm install -g ackee@3.5.0 -
Commit and push the changes to GitHub:
Terminal window git add Dockerfilegit commit -m "Upgrade Ackee to version 3.5.0"git push -
Klutch.sh will automatically rebuild and redeploy your application
-
Your data will be preserved because it’s stored in the persistent volume
Additional Resources
- Klutch.sh Documentation
- Ackee GitHub Repository
- Official Ackee Documentation
- Klutch.sh Volumes Guide
- Klutch.sh Networking Guide
- Node.js Docker Images
- MongoDB Docker Images
Conclusion
Deploying Ackee to Klutch.sh with Docker provides a privacy-focused, self-hosted analytics solution with persistent storage and easy scalability. By following this guide, you’ve set up a production-ready Ackee instance with proper data persistence, security configurations, and tracking capabilities. Your analytics platform is now ready to provide valuable insights into your website’s traffic while respecting user privacy and maintaining full control over your data.