This package allows you to integrate a simple analytics dashboard widget for panel.
You can install the package via composer:
composer require devlogx/filament-fathom-dashboard-widget
Get the Fathom API-Token and add it your env
file.
.env
file:# ...FATHOM_API_TOKEN="xxxxx|xxxxxxxxxxxxxxxxxxx"FATHOM_SITE_ID="XXXXXXX"
You can publish the config file with:
php artisan vendor:publish --tag="filament-fathom-dashboard-widget-config"
Optionally, you can publish the translations using
php artisan vendor:publish --tag="filament-fathom-dashboard-widget-translations"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Fathom API-Token & Site id |-------------------------------------------------------------------------- | | You can acquire your API-Token from the url below: | https://app.usefathom.com/api | */ 'api_token' => env('FATHOM_API_TOKEN'), 'site_id' => env('FATHOM_SITE_ID'), /* |-------------------------------------------------------------------------- | Fathom Domain |-------------------------------------------------------------------------- | | If you're from the EU, I can recommend using the EU CDN: | cdn-eu.usefathom.com | */ 'domain' => env('FATHOM_DOMAIN', 'cdn.usefathom.com'), /* |-------------------------------------------------------------------------- | Stats cache ttl |-------------------------------------------------------------------------- | | This value is the ttl for the displayed dashboard | stats values. You can increase or decrease | this value. | */ 'cache_time' => 300,];
Under Filament/Pages/
create a new file called Dashboard.php
with following contents:
<?php namespace App\Filament\Pages; use Devlogx\FilamentFathom\Concerns\HasFilter; class Dashboard extends \Filament\Pages\Dashboard{ use HasFilter; }
->pages([ //Pages\Dashboard::class,])
Alternatively if you already have a custom Dashboard, add the HasFilter
trait to your Dashboard file.
->widgets([ Widgets\AccountWidget::class, Widgets\FilamentInfoWidget::class, \Devlogx\FilamentFathom\Widgets\FathomStatsWidget::class,// <-- add this widget])
->plugins([ \Devlogx\FilamentFathom\FilamentFathomPlugin::make()])
->plugins([ \Devlogx\FilamentFathom\FilamentFathomPlugin::make() ->fathomLink(true) //Direct link to fathom analytics page ->pollingInterval("60s") //Auto polling interval ->filterSectionIcon("heroicon-s-adjustments-vertical") ->filterSectionIconColor("primary") ->liveVisitorIcon("heroicon-s-user") //First Block | Live Visitors ->liveVisitorColor("primary") //First Block | Live Visitors ->visitorsIcon("heroicon-s-user-group") //Second Block | All Visitors ->visitorsColor("primary") //Second Block | All Visitors ->viewsIcom("heroicon-s-eye") //Third Block | All Page Views ->visitorsColor("primary") //Third Block | All Page Views ->sessionTimeIcon("heroicon-s-clock") //Fourth Block | Avg. Session Time ->sessionTimeColor("primary") //Fourth Block | Avg. Session Time])
You can use the functions for your own widgets. There are plenty more available.
 use Devlogx\FilamentFathom\Facades\FilamentFathom; $dashboardLink = FilamentFathom::getDashboardLink();
use Devlogx\FilamentFathom\Concerns\Filter;Â $filter = (new Filter()) ->setFrom(Carbon::now()->subDays(30)) ->setTo(Carbon::now());
use Devlogx\FilamentFathom\Facades\FilamentFathom;Â //Get active visitors$activeVisitors = FilamentFathom::activeVisitors($filter,false);Â //Get avg session duration$sessionDuration = FilamentFathom::sessionDuration($filter,false);Â //Get visitors$visitors = FilamentFathom::visitors($filter,false);Â //Get page views$views = FilamentFathom::views($filter,false);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
Develogix Agency, based in Austria, is a Fullstack web development firm specializing in the TALL stack and Filament. Known for delivering robust and efficient digital solutions, Develogix excels in creating intuitive and sophisticated web experiences tailored to diverse client needs.