jeffersongoncalves/filament-metrics-ga4
Filament plugin that brings Google Analytics 4 metrics into your admin dashboard. Display GA4 sessions, users, page views, and other key stats as native Filament widgets, so you can monitor traffic and performance without leaving your panel. Requires a Google service account for GA4 Data API access.
This package is a Filament plugin that registers an analytics settings page in your panel. Start by installing it alongside its core dependency filament-analytics-core (v3.1+ is required for the newest navigation features):
composer require vendor/filament-analytics
Register the plugin on your Filament panel provider — this is where most day-to-day configuration lives:
use Vendor\FilamentAnalytics\Plugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
Plugin::make(),
]);
}
Look first at the Plugin class (the fluent entry point) and any published config file (php artisan vendor:publish --tag=filament-analytics-config) — that's where data sources, credentials, and display options are wired. The first use case is almost always: mount the default settings/analytics page, confirm it renders in your panel, then point it at a real data source.
Customizing navigation placement (new in 3.1.0). By default the page lives in the plugin's translated navigation group. To fold it into one of your panel's existing groups — e.g. "Reporting" or "Settings" — use the new fluent method:
Plugin::make()
->navigationGroup('Reporting'),
Because the signature accepts string|Closure, you can resolve the group dynamically (per-tenant panels, role-based layouts, localization):
Plugin::make()
->navigationGroup(fn () => auth()->user()->isAdmin() ? 'Administration' : 'Reporting'),
Panel-scoped registration. Register different plugin configurations per panel when you have multiple Filament panels (admin vs. tenant). Each panel instance can carry its own navigationGroup, keeping the analytics page co-located with the rest of that panel's IA.
Compose with other plugin options. Treat navigationGroup() as one link in a fluent chain — set it alongside whatever analytics configuration the plugin already exposes (data source, refresh cadence, widget toggles). Keep the chain readable by breaking it across lines.
Integration tip: if your panel already defines navigation groups explicitly via ->navigationGroups([...]), pass a matching label string to navigationGroup() so Filament doesn't create a silent duplicate group. When in doubt, use a Closure that returns the canonical label from a shared constant.
navigationGroup() is only available on filament-analytics-core 3.1+. If you pin core below 3.1 you won't get the method (and on this plugin 3.1.0 the call may silently no-op or error depending on how it's guarded). Bump core in the same PR.navigationGroup() keeps the translated group — this is intentional and non-breaking. Existing installs need no changes.Closure is evaluated when the page is registered/navigated, not at boot. Don't rely on request-scoped state that isn't available at that point (e.g. route params on the navigation render).__() yourself or return a translated string from the Closure.navigationGroup registrations across plugins and any panel-level default. php artisan filament:optimize-clear (and a cache clear) resolves stale navigation caches after config changes.Closure signature is the cleanest hook for multi-tenant/role-aware navigation — prefer it over subclassing Plugin so you stay on the supported upgrade path.How can I help you explore Laravel packages today?