Google Analytics plugin screenshot
Dark mode ready
Multilingual support
Supports v5.x

Google Analytics by Bezhan Salleh

Community

Google Analytics integration for Filament Panels with a set of widgets to display your Google Analytics data in a beautiful way.

Tags: Analytics Spatie Integration Widget
Supported versions:
5.x 4.x 3.x 2.x
Bezhan Salleh avatar Author: Bezhan Salleh

Package health

Automated checks of this plugin's Composer package

100 / 100
Security 100
Maintenance 100
Ecosystem 100
15 checks
  • Passed: GitHub Actions pinned to SHA
  • Skipped: GitLab CI includes pinned to SHA
  • Passed: Open security advisories
  • Passed: Dependabot PR responsiveness — No open Dependabot PRs.
  • Skipped: Renovate MR responsiveness
  • Passed: Dependabot or Renovate configured
  • Passed: Dependency update cooldown configured
  • Passed: Provides a security policy
  • Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
  • Passed: Commit and release recency — Active: last commit 0 days ago; last release 221 days ago.
  • Passed: composer.lock not committed by library — composer.lock is absent from the released dist archive.
  • Passed: Dist archive is lean
  • Passed: Current Laravel version supported — Package dependencies resolve together with current Laravel 13.0.
  • Passed: Current PHP version supported — Constraint ^8.3 supports current PHP 8.5.
  • Skipped: Current Symfony version supported
Third-party plugin. This is built by the community, not the Filament team. Filament does not review, endorse, or vet the security of plugins outside the filament/ namespace. Review the source and install at your own risk. Found malware or an unresolved security issue the author won't address? Report it .
Powered by Plumb Last scanned 1 week ago

Documentation

Version:
filament-google-analytics-art

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

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.

The author

Bezhan Salleh avatar Author: Bezhan Salleh

Bezhan Salleh is a full-stack developer with a strong focus on backend development and a passion for open-source. He’s the creator of Shield, Filament’s most starred plugin, and the author of other popular plugins, including Plugin Essentials and Google Analytics. His work focuses on delivering practical, powerful solutions with an emphasis on performance and developer experience.

Plugins
6
Stars
2.5K

From the same author