Laravel Plausible
A lightweight Laravel package that seamlessly integrates Plausible Analytics into your Blade views. Plausible.io is a privacy-friendly, open-source alternative to Google Analytics.
#Laravel Plausible
A lightweight Laravel package that seamlessly integrates Plausible Analytics into your Blade views. Plausible.io is a privacy-friendly, open-source alternative to Google Analytics.
Settings are stored in the database using spatie/laravel-settings, making it easy to manage from an admin panel or programmatically.
#Installation
Install the package via Composer:
composer require jeffersongoncalves/laravel-plausible
Publish and run the settings table migration from spatie/laravel-settings (if not already done):
php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider" --tag="migrations" php artisan migrate
Publish and run the Plausible settings migration:
php artisan vendor:publish --tag=plausible-settings-migrations
php artisan migrate
#Usage
#Include the script in your layout
Add the following to your Blade layout (inside <head>):
@include('plausible::script')
The script tag will only be rendered when the domains setting is configured.
#Configure settings
You can update the settings programmatically:
use JeffersonGoncalves\Plausible\Settings\PlausibleSettings; $settings = app(PlausibleSettings::class); $settings->domains = 'example.com'; $settings->save();
#Available settings
| Setting | Type | Default | Description |
|---|---|---|---|
domains |
?string |
null |
Domain(s) to track. Supports rollup reporting with comma-separated domains. |
host_analytics |
string |
https://plausible.io |
Plausible host URL. Change this if you are self-hosting Plausible. |
#Self-hosted Plausible
If you are self-hosting Plausible, update the host_analytics setting:
$settings = app(PlausibleSettings::class); $settings->host_analytics = 'https://analytics.example.com'; $settings->save();
#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.