Umami Analytics for Statamic
This Statamic addon makes it easy to connect your site to a self-hosted Umami instance.
It provides:
- 🧩 A tag to embed the Umami tracking script on your front-end pages
- 📊 A Control Panel widget to view your Umami stats right inside Statamic
Features
✅ Add tracking to your Statamic templates with {{ umami }}
✅ Show Umami stats like visitors, page views, bounce rate, and visit duration
✅ Configure via environment variables and the config/statamic/cp.php
widget array
✅ Multi-language support (English, German)
🚧 Time range selection coming soon
Requirements
- Statamic 5.x
- PHP 8.2 or higher
- A running, self-hosted Umami instance with API access
This addon currently works with self-hosted Umami only. Umami Cloud with API keys is not supported yet.
Installation
Install via Composer:
composer require mynetx/umami
Configuration
Environment Variables
Add these to your .env
file:
UMAMI_HOST=https://analytics.example.comUMAMI_USERNAME=your-usernameUMAMI_PASSWORD=your-passwordUMAMI_WEBSITE_ID=your-website-idUMAMI_TEAM_ID=your-team-id
Variable | Description | Example |
---|---|---|
UMAMI_HOST |
Your Umami base URL | https://analytics.example.com |
UMAMI_USERNAME |
Umami login username | admin |
UMAMI_PASSWORD |
Umami password | secure_password |
UMAMI_WEBSITE_ID |
Website ID from your Umami site | abc123 |
UMAMI_TEAM_ID |
Team ID (if applicable) | abc123 |
Find your website and team IDs in the URL when viewing your Umami dashboard.
Widget Setup
To display stats in the Control Panel dashboard:
- Open
config/statamic/cp.php
- Locate the
widgets
array - Add an entry for the Umami widget:
'widgets' => [ [ 'type' => 'umami_stats', 'title' => 'My Umami Stats', 'host' => env('UMAMI_HOST'), 'username' => env('UMAMI_USERNAME'), 'password' => env('UMAMI_PASSWORD'), 'website_id' => env('UMAMI_WEBSITE_ID'), 'team_id' => env('UMAMI_TEAM_ID'), 'timeframe' => '7d', // 24h, 7d, 30d, or 90d ],],
💡 You can hardcode values or pull them from environment variables.
Tracking Setup
To embed the Umami tracking script in your site, add this to your Antlers layout or template:
{{ umami }}
or explicitly:
{{ umami:script }}
The script is only included when the current environment matches the enabled_environments
config setting:
'enabled_environments' => ['production'],
Set it to null
to allow output on all environments.
How It Works
This addon connects to your Umami instance via these API endpoints:
POST /api/auth/login
— Authenticate and retrieve an access tokenGET /api/websites/{websiteId}/stats
— Fetch your website’s analytics
Refer to the Umami API documentation for more details.
License
MIT License