
Matomo Widget for Statamic
Requirements
- PHP 8.3+
- Statamic 6.0+
Using Statamic 3.3, 4, or 5? Stay on the
1.xrelease (composer require jeroenpeters1986/statamic-matomo-widget:^1.0). Version2.xtargets Statamic 6's Vue 3 / Vite Control Panel.
Installation
Install via the Control Panel or via Composer:
composer require jeroenpeters1986/statamic-matomo-widget
If assets are not automatically published during installation, publish the compiled widget assets with:
php artisan vendor:publish --tag=statamic-matomo-widget --force
Environment variables
Add the following to your .env file:
MATOMO_URL=https://your-matomo-urlMATOMO_SITE_ID=1MATOMO_API_TOKEN=your-token-auth
Optional environment variables:
MATOMO_CACHE_MINUTES=5MATOMO_WIDGET_TITLE="Matomo Statistics"MATOMO_WIDGET_DAYS=30
Enable Widget
Add the widget to your Control Panel configuration in config/statamic/cp.php:
'widgets' => [ [ 'type' => 'matomo', 'width' => 50, ],],
You can also override widget options per dashboard entry:
[ 'type' => 'matomo', 'width' => 50, 'title' => 'Matomo Statistics', 'chart_type' => 'line', // 'line' or 'bar' 'chart_height' => 300, 'days' => 30, 'metrics' => ['nb_visits', 'nb_actions'],],
Customizing configuration
You can publish the config file with:
php artisan vendor:publish --tag=matomo-widget-config
This creates config/statamic/matomo_widget.php where you can customize defaults for url, site_id, token, cache_minutes, and widget (title, days, metrics, chart_type, chart_height).
Building assets (for contributors)
composer install # installs statamic/cms 6.23+ needed for the @statamic/cms npm packagenpm installnpm run build
The compiled assets in resources/dist/ are shipped with the package and run on any Statamic 6 version (6.0+); the 6.23+ requirement only applies to building the frontend locally.
Support
I love to share with the community. Nevertheless, coding/learning/updating takes a lot of work, time and effort. You can contact me through my personal site https://jeroenpeters.dev/contact, or if you have any issues with this package, please create an issue on GitHub.
If you like my software, feel free to buy me a coffee or two with Ko-Fi
Changelog
2.0.0
- Added Statamic 6 support (Vue 3
<Widget>component, Vite build, locally bundled Chart.js) - Enforced PHP
^8.3and Statamic^6.0constraints incomposer.json - Fixed caching duration (minutes instead of seconds) and per-site/date cache keys
- Wired
widget.metrics,widget.chart_height,widget.days, andwidget.titleconfiguration options - Improved unconfigured and API error states without exposing credentials or raw responses
1.0.2
Updated docs, reverted the viewNamespace, merged config
1.0.1
Added loading-stuff
1.0.0
First version
License
This plugin is published under the MIT license.
Other..
Disclaimer
This add-on is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Matomo / Piwik, or any of its subsidiaries or its affiliates. This add-on merely enables users to easily access their stats.