mettr / statamic
mettr for Statamic: live page views, form submissions, sign-ups, crawlers and errors, with an Antlers tag
Requires
- php: ^8.3
- mettr/laravel: ^0.3.0
- statamic/cms: ^6.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.0
- pestphp/pest-plugin-laravel: ^4.0|^5.0
- pestphp/pest-plugin-type-coverage: ^4.0|^5.1
- shipfastlabs/pun: 0.4.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Sends a Statamic site's page views, form submissions, sign-ups, crawlers,
404s and errors to mettr, as they happen. Statamic 6,
PHP 8.3+. Built on mettr/laravel,
which it installs.
Install
composer require mettr/statamic
Add the site's keys (mettr, site settings, "Tracking") to .env:
METTR_SECRET_KEY=sk_... METTR_PUBLIC_KEY=pk_...
and the script to the <head> of your layout:
{{ mettr }}
(@mettr in a Blade layout.) It sends from production only; set
METTR_ENABLED=true to try it elsewhere.
What it sends
Everything mettr/laravel sends: page views and who is online from the
script (through /_live on your own domain), sign-ins, 404s, exceptions by
class, response times and crawler visits. And, for Statamic:
- Form submissions (
form_submitted), with the form's handle only: never what was typed in it. - Sign-ups through Statamic's registration form (
signup), as the new user's. - Nothing from the control panel: its route (
cp, or yours) is added tomettr.ignore, so editors at work are not traffic. - People who may use the control panel are staff: their visits send
nothing, unless you name your own gate in
METTR_STAFF_GATE.
Turn forms off with mettr.track.forms in config/mettr.php
(php artisan vendor:publish --tag=mettr-config).
Static caching
With full static caching the web server answers from HTML files and PHP never runs: the script still counts page views and who is online, but crawler visits, 404s and response times of cached pages are not seen. Half-measure caching keeps them.
Your own events
use Mettr\Laravel\Facades\Mettr; Mettr::event('newsletter', ['list' => 'weekly']);
Your MCP server
If the site runs an MCP server (laravel/mcp, or an addon that adds
one), put mettr/laravel's mettr.mcp middleware first on its route,
so mettr shows how AI assistants use it (calls, tools, clients, failures
and time, never what a call carried) and sends no crawl for it:
Mcp::web('/mcp', SiteServer::class)->middleware(['mettr.mcp', 'auth:api']);
See MCP analytics; the panels come with Pro.
License
MIT.