laravel-simple-analytics maintained by jeffersongoncalves

Laravel Simple Analytics
Add Simple Analytics — privacy-first, GDPR-compliant analytics without cookies — to your Laravel app. The settings are stored in the database with spatie/laravel-settings, so you can change them at runtime (e.g. from an admin panel) instead of in .env.
For a Filament settings page, use jeffersongoncalves/filament-simple-analytics.
Installation
composer require jeffersongoncalves/laravel-simple-analytics
Publish and run the settings migration:
php artisan vendor:publish --tag=simple-analytics-settings-migrations
php artisan migrate
Configuration
$settings = simple_analytics_settings();
$settings->enabled = true;
$settings->hostname = 'example.com';
$settings->save();
Or through the settings class or the Facade:
use JeffersonGoncalves\SimpleAnalytics\Facades\SimpleAnalytics;
use JeffersonGoncalves\SimpleAnalytics\Settings\SimpleAnalyticsSettings;
$settings = app(SimpleAnalyticsSettings::class);
$value = SimpleAnalytics::getFacadeRoot()->enabled;
Available settings
| Setting | Type | Default | Description |
|---|---|---|---|
enabled |
bool |
false |
Load the Simple Analytics script. No ID needed: visits are matched by domain. |
hostname |
?string |
null |
Optional domain to report the visits under (data-hostname). |
Usage
Add the script to your Blade layout, inside <head>:
@include('simple-analytics::script')
Nothing is rendered until the settings are complete, so you can ship the include everywhere and turn Simple Analytics on later.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.