Analytics setup guide
Learn how to integrate Google Analytics 4 and Umami Analytics with EasyAPI
Overview
EasyAPI integrates with popular analytics platforms to help you track user behavior and site performance:
- Google Analytics 4 (GA4): The latest version of Google's analytics platform, suited to full user behavior analysis and conversion tracking.
- Umami Analytics: A privacy-focused, open-source analytics tool with lightweight deployment and cookie-free tracking, suited to self-hosted or compliance-sensitive environments.
You can enable both analytics tools at the same time without conflicts.
Features
- Zero-code integration: configured entirely through environment variables
- Scripts are injected into the web UI automatically
- Works with Docker Compose and standalone deployments
- Privacy-conscious implementation
- No frontend code changes required
Google Analytics 4 setup
1. Get your measurement ID
- Go to Google Analytics
- Create a new property or select an existing one
- Open Admin → Data streams
- Create or select a web data stream
- Copy your Measurement ID (format:
G-XXXXXXXXXX)
2. Configure environment variables
Docker Compose: edit docker-compose.yml and add the following under environment:
environment:
- GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX # Replace with your actual measurement IDStandalone deployment: add it to your .env file or set it as an environment variable:
export GOOGLE_ANALYTICS_ID=G-XXXXXXXXXXDocker Run:
docker run -d \
-e GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX \
...other options... \
easyapi/easyapi:latest3. Restart the application
# Docker Compose
docker-compose down && docker-compose up -d
# Standalone deployment
# Restart your EasyAPI applicationUmami Analytics setup
1. Get your Umami credentials
Option A: Umami Cloud
- Sign up for Umami Cloud
- Add a new website
- Copy your Website ID (UUID format)
Option B: Self-hosted Umami
- Deploy your own Umami instance
- Create a website in the dashboard
- Copy your Website ID and Script URL
2. Configure environment variables
Docker Compose:
environment:
- UMAMI_WEBSITE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# Optional: only required for self-hosted instances
- UMAMI_SCRIPT_URL=https://your-umami-domain.com/script.jsStandalone deployment:
export UMAMI_WEBSITE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export UMAMI_SCRIPT_URL=https://your-umami-domain.com/script.js # OptionalNote: If you use Umami Cloud, you don't need to set UMAMI_SCRIPT_URL; the official script URL is used by default.
3. Restart the application
Same as Google Analytics: restart EasyAPI to apply the changes.
Using both analytics tools
You can enable Google Analytics and Umami at the same time:
environment:
- GOOGLE_ANALYTICS_ID=G-ABC123XYZ
- UMAMI_WEBSITE_ID=a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6
- UMAMI_SCRIPT_URL=https://analytics.umami.is/script.jsVerification
After restarting, open your browser's developer tools (F12) → Network and look for these requests:
- Google Analytics:
https://www.googletagmanager.com/gtag/js - Umami: the script URL you configured
You can also view the page source and look for the injected scripts in the <head> section.
Troubleshooting
Analytics not working?
- Verify that the environment variables are set correctly
- Restart the application after changing variables
- Check the browser console for errors
- Make sure the measurement ID or website ID format is correct
- Check whether an ad blocker is interfering
Docker users:
docker exec <container-name> env | grep -E "GOOGLE_ANALYTICS|UMAMI"Privacy considerations
- Google Analytics collects user data under Google's privacy policy
- Umami is privacy-focused and does not collect personal data
- If you use analytics, consider adding a privacy policy to your site
- Both tools are GDPR-compliant when configured correctly
Environment variable reference
| Variable | Required | Default | Description |
|---|---|---|---|
GOOGLE_ANALYTICS_ID | No | - | Google Analytics 4 measurement ID (format: G-XXXXXXXXXX) |
UMAMI_WEBSITE_ID | No | - | Umami website ID (UUID format) |
UMAMI_SCRIPT_URL | No | https://analytics.umami.is/script.js | Umami script URL (customize for self-hosted instances) |