jeffersongoncalves / 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.
Installs: 21
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
pkg:composer/jeffersongoncalves/laravel-plausible
Requires
- php: ^8.2|^8.3
- laravel/framework: ^11.0|^12.0|^13.0
- spatie/laravel-package-tools: ^1.14.0
- spatie/laravel-settings: ^3.0
Requires (Dev)
- larastan/larastan: ^3.0
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.7.4
- pestphp/pest-plugin-laravel: ^3.0
README
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.
