New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP
259,781 216
Install
composer require bezhansalleh/filament-google-analytics
Latest Version:3.4.0
PHP:^8.3
Laravel:11 · 12 · 13
Older releases:9 · 10
License:MIT
Last Updated:Nov 5, 2026
Links: GitHub  ·  Packagist
Maintainer: bezhanSalleh
filament-google-analytics-art

FILAMENT 4.x FILAMENT 5.x Packagist Tests Passing Code Style Passing Downloads

Google Analytics (GA4)

Bring your Google Analytics 4 data into Filament Panels. The plugin ships a dedicated dashboard page and a set of widgets that show page views, visitors, sessions, active users, devices, countries, top pages and referrers, each with its own period filter.

Installation

Install the package with Composer:

composer require bezhansalleh/filament-google-analytics

The plugin reads your analytics data through Spatie's Laravel Analytics package. Follow its guide to create a service account and download the credentials, then place the file at:

storage/app/analytics/service-account-credentials.json

Add your GA4 property ID to your .env file:

ANALYTICS_PROPERTY_ID=

[!IMPORTANT] The plugin follows Filament's theming rules. Create a custom theme if you haven't already, then add the following lines to your theme's CSS file:

@source '../../../../vendor/bezhansalleh/filament-google-analytics/resources/views/**/*';
@source '../../../../vendor/bezhansalleh/filament-google-analytics/src/{Widgets,Support}/*';

Register the plugin in your panel provider:

use BezhanSalleh\GoogleAnalytics\GoogleAnalyticsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            GoogleAnalyticsPlugin::make(),
        ]);
}

Configuration

Publish the config file to change the defaults:

php artisan vendor:publish --tag=google-analytics-config

The config file lets you:

  • Enable or disable the dedicated dashboard page and set its navigation icon.
  • Control where each widget appears through its filament_dashboard and global options. See Widget Visibility.
  • Change the icons and colors the stat widgets use for upward, downward and steady trends.

Usage

Dedicated Dashboard

The plugin registers a Google Analytics page in your panel's navigation and renders every widget on it. Set dedicated_dashboard to false in the config file to remove the page.

Available Widgets

use BezhanSalleh\GoogleAnalytics\Widgets;

Widgets\PageViewsWidget::class,
Widgets\VisitorsWidget::class,
Widgets\ActiveUsersOneDayWidget::class,
Widgets\ActiveUsersSevenDayWidget::class,
Widgets\ActiveUsersTwentyEightDayWidget::class,
Widgets\SessionsWidget::class,
Widgets\SessionsByCountryWidget::class,
Widgets\SessionsDurationWidget::class,
Widgets\SessionsByDeviceWidget::class,
Widgets\MostVisitedPagesWidget::class,
Widgets\TopReferrersListWidget::class,

Widget Visibility

Each widget has two options in the config file:

Option Effect
filament_dashboard Show the widget on Filament's default dashboard. Off by default.
global Show the widget on the dedicated dashboard and on any other page where you register it.

Set filament_dashboard to true for every widget you want on Filament's own dashboard.

Custom Dashboard

The dedicated dashboard is a plain Filament page. To change its navigation label or group, pick a subset of widgets, or apply any other customization, disable the dedicated dashboard and create your own page:

php artisan make:filament-page MyCustomDashboardPage

Register the widgets you want in getHeaderWidgets() or getFooterWidgets():

<?php

namespace App\Filament\Pages;

use BezhanSalleh\GoogleAnalytics\Widgets;
use Filament\Pages\Page;

class MyCustomDashboardPage extends Page
{
    protected static ?string $navigationIcon = 'heroicon-o-document-text';

    protected string $view = 'filament.pages.my-custom-dashboard-page';

    protected function getHeaderWidgets(): array
    {
        return [
            Widgets\PageViewsWidget::class,
            Widgets\VisitorsWidget::class,
            Widgets\ActiveUsersOneDayWidget::class,
            Widgets\ActiveUsersSevenDayWidget::class,
            Widgets\ActiveUsersTwentyEightDayWidget::class,
            Widgets\SessionsWidget::class,
            Widgets\SessionsByCountryWidget::class,
            Widgets\SessionsDurationWidget::class,
            Widgets\SessionsByDeviceWidget::class,
            Widgets\MostVisitedPagesWidget::class,
            Widgets\TopReferrersListWidget::class,
        ];
    }
}

Preview

The widgets rendered on the dedicated dashboard. They look the same on any page you add them to.

Demo Demo

Upgrading

When you upgrade from 2.x to 3.x, replace the BezhanSalleh\FilamentGoogleAnalytics namespace with BezhanSalleh\GoogleAnalytics everywhere you reference the plugin.

Testing

composer test

Version Support

Only the latest major plugin line receives active development. Older lines stay installable for legacy projects but get no new features; they only receive security fixes while their Filament target is still supported upstream.

Plugin Filament Status
3.x v4 & v5 Active — new features + bug fixes (lives on main)
2.x v3 End of life — follows Filament v3 EOL
1.x v2 End of life

See CHANGELOG for migration notes between majors.

Changelog

See CHANGELOG for the list of recent changes.

Contributing

If you want to contribute to this package, test it in a real Filament project:

  • Fork this repository to your GitHub account.
  • Create a Filament app locally.
  • Clone your fork in your Filament app's root directory.
  • In the /filament-google-analytics directory, create a branch for your fix, e.g. fix/error-message.

Install the package in your app's composer.json:

"require": {
    "bezhansalleh/filament-google-analytics": "dev-fix/error-message as main-dev",
},
"repositories": [
    {
        "type": "path",
        "url": "filament-google-analytics"
    }
]

Now, run composer update.

See CONTRIBUTING for details.

Security Vulnerabilities

Review our security policy to learn how to report security vulnerabilities.

Credits

License

The MIT License (MIT). See the License File for more information.

Related Packages

Version History

Version Released PHP Laravel License
3.4.0 ^8.3 ^11.28|^12.0|^13.0 MIT
3.3.0 ^8.3 ^11.28|^12.0|^13.0 MIT
3.2.0 ^8.3 ^11.28|^12.0 MIT
3.1.0 ^8.3 ^11.28|^12.0 MIT
3.0.1 ^8.2 ^11.28|^12.0 MIT