mattitjaab / laravel-plausible-proxy
A Laravel package for proxying Plausible Analytics, improving performance and privacy.
Fund package maintenance!
Mattitja AB
Requires
- php: ^8.3
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2025-06-25 19:36:23 UTC
README
A Laravel package for proxying Plausible Analytics, improving performance.
Requirements
- Laravel 12
- PHP 8.3, 8.4
🚀 Installation
-
Install the package via Composer:
composer require mattitjaab/laravel-plausible-proxy
-
Publish the configuration file:
php artisan vendor:publish --tag=plausible-proxy-config
-
Add the following environment variables to your
.env
file:PLAUSIBLE_DOMAIN=https://plausible.io
⚙️ Configuration
The config/plausible-proxy.php
file allows you to customize the plausible domain:
return [ 'domain' => env('PLAUSIBLE_DOMAIN', 'https://plausible.io'), ];
🔥 Usage
1. Proxying the JavaScript file
This package proxies Plausible's script.js
while caching it to improve performance and reduce external requests.
After installation, you can include the script like this:
<script defer data-domain="example.com" src="/js/script.js"></script>
The route /js/script.js
is automatically handled and caches the script for 6 hours.
2. Sending Events to Plausible
Instead of sending events directly to plausible.io, the script is loaded from /js/script.js and proxies the request to Plausible via /api/event, helping to prevent blocking by ad blockers.
✅ Features
- 🚀 Fast & Optimized: Caches the Plausible script to reduce external calls.
- ✅ No issues with ad blockers: Proxies the request via a local API endpoint.
- 🛠 Fully Configurable: Easily set your own Plausible instance via
.env
.
🛠 Testing
You can run tests with:
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.