Appearance
Analytics
Google Analytics 4, Plausible, Matomo or Yandex Metrica on the site's pages.
kitloom/analytics · admins: kitloom/analytics-filament, kitloom/analytics-nova
Video lessons
Recorded in the Filament admin; the Nova admin works the same way.
Counts the site's visits with Google Analytics 4, Plausible, Matomo or Yandex Metrica. Any one of them works, or several at once. It does what Site Kit, MonsterInsights, the Plausible plugin, Connect Matomo or the Yandex Metrica plugin did on the WordPress site, and their settings can be imported. The admin page is the Analytics section (kitloom/analytics-filament or kitloom/analytics-nova).
Setting it up
Open Analytics → Settings and fill in the service you use. An empty ID means that service is off.
| Service | What to enter | Where to find it |
|---|---|---|
| Google Analytics 4 | Measurement ID, G-XXXXXXXXXX | Google Analytics → Admin → Data streams → the site's stream |
| Plausible | The domain, as added in Plausible | Plausible → the site → Site settings |
| The script, if not the default | Site settings → Site installation: the site's own pa-….js, a self-hosted Plausible's https://stats.example.com/js/script.js, or a script with extensions (script.outbound-links.file-downloads.js) | |
| Matomo | The Matomo address and the site ID | Matomo → Administration → Websites → Manage |
| Yandex Metrica | The counter's number | Metrica → the counter's settings. Webvisor is a separate switch |
The counters go into the head of every page of the theme, where the theme put @siteHead.
Consent
With the Cookie Consent module installed, each counter waits for the visitor's answer:
| Service | Needs consent to |
|---|---|
| Google Analytics 4 | statistics. With Google Consent Mode on in Cookie Consent, it loads at once with every signal denied and follows the visitor's answer. |
| Plausible | nothing by default: it sets no cookies and keeps no personal data. Count without consent off makes it wait for statistics. |
| Matomo | statistics. With Without cookies on, it counts without consent (Matomo then cannot tell a returning visitor from a new one). |
| Yandex Metrica | statistics |
Without a consent module, every counter loads at once.
Who is counted
Signed-in users (editors, administrators, customers with an account) are not counted by default, so the site's own people do not skew the numbers. Count signed-in users turns that off. Pages for guests are cached as before: a signed-in user's page is always drawn anew, so leaving the counter out of it affects nobody else.
Pages without a reload
In an Inertia theme, the next page opens without a reload:
- Google Analytics counts these pages itself, through its "page changes based on browser history" measurement (on by default).
- Plausible counts them itself too.
- Matomo and Yandex Metrica are sent each new page by the module.
Shop sales
With the shop module, Google Analytics also receives the shop's e-commerce events:
view_item— a product page is opened;add_to_cart— a product goes into the cart;begin_checkout— the checkout form is opened;purchase— the "order received" page is shown, with the order number, total, tax and shipping.
They appear in GA4's Monetization reports without any setup. Each order is sent once per browser, however often its page is opened again. A failed or cancelled order is not sent.
The other services here count visits only.
Coming from WordPress
If the WordPress site had one of these plugins, the settings page shows an Import button. The console command does the same:
bash
php artisan analytics:import
php artisan analytics:import --from=sitekit --from=plausible| Plugin | What is taken |
|---|---|
| Site Kit by Google | The GA4 measurement ID, if Site Kit placed the tag. Whether signed-in users were excluded. |
| MonsterInsights | The GA4 ID, connected or entered by hand. If any roles were excluded, signed-in users stay uncounted. |
| Plausible Analytics | The domain, and the site's script or the self-hosted address. |
| Connect Matomo | The Matomo address (including a Matomo Cloud account), the site ID, and "without cookies". |
| Yandex Metrica | The first counter and its Webvisor setting. |
The plugins' options are not touched. What a plugin did not set stays as it is here.
Not carried over:
- Matomo's extra tracking (404s, site search, user ID).
- Plausible's custom properties and excluded pages.
- MonsterInsights' per-role exclusions. Only "signed-in or not" is kept.
For developers
- Settings:
analytics_*, declared byAnalyticsOptionsand written throughSettingWriter. - How the counters reach the page:
AnalyticsScriptsis thePageScriptsProvider.- Each service is a
Trackers\Trackerwith its snippet and consent category. - Every snippet goes through kitloom/site's
ScriptConsent::gate(). GA4 says it reads Google Consent Mode.
- CSP: a nonce set with
Vite::useCspNonce()goes on the scripts. - Config:
php artisan vendor:publish --tag=kitloom-analytics-configpublishes the admin sections switch (filament.register,nova.register). - Tests, from the application that installs the package:
php vendor/bin/phpunit --testsuite Analytics.