Analytics
Umami analytics integration
Analytics
What's Included
- Umami analytics integration (privacy-friendly, cookie-free)
- Runtime configuration via environment variables
- Automatic script injection (client-side only)
- Localhost detection (skips tracking in development)
Setup
Umami is optional and configured via environment variables:
NUXT_PUBLIC_UMAMI_HOST=https://analytics.yourdomain.com
NUXT_PUBLIC_UMAMI_ID=your-site-id
If these variables are not set, the analytics plugin is not loaded and no tracking script is injected.
How It Works
The umami.client.ts plugin:
- Reads
NUXT_PUBLIC_UMAMI_HOSTandNUXT_PUBLIC_UMAMI_IDfrom runtime config - Skips injection if either is missing
- Skips injection on
localhostin production mode - Injects the Umami tracking script into the page
<head>
Why Umami?
- Privacy-friendly — no cookies, GDPR-compliant out of the box
- Self-hosted — you own your data
- Lightweight — ~2KB tracking script
- Open source — free to self-host
Self-Hosting Umami
You can run Umami alongside your app using Docker:
- Deploy Umami (see umami.is)
- Create a website in the Umami dashboard
- Copy the Website ID
- Set
NUXT_PUBLIC_UMAMI_HOSTandNUXT_PUBLIC_UMAMI_IDin your frontend environment
Verification
- Visit your deployed website and view the page source (
Ctrl+U) - Search for
data-website-id— you should see the Umami tracking script - Check your Umami dashboard for page views and real-time visitors
In development mode, check the browser console — missing variables will show a warning: [Umami] Tracking disabled: NUXT_PUBLIC_UMAMI_HOST or NUXT_PUBLIC_UMAMI_ID not configured
Troubleshooting
Script not appearing — Verify environment variables are set with NUXT_PUBLIC_ prefix and restart the application.
No data in Umami dashboard — Verify the website ID matches, the Umami host URL is accessible, and CORS is configured on your Umami instance.
CSP errors — The CSP in nuxt.config.ts includes wildcard https: for scripts and connections. If you need stricter rules, add your specific Umami host URL.
Works locally but not in production — Check that environment variables are set in your deployment platform and that the production server can reach the Umami host.