mattitjaab/laravel-plausible-proxy

A Laravel package for proxying Plausible Analytics, improving performance and privacy.

v1.5 2025-06-25 19:34 UTC

This package is auto-updated.

Last update: 2025-06-25 19:36:23 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel package for proxying Plausible Analytics, improving performance.

Requirements

  • Laravel 12
  • PHP 8.3, 8.4

🚀 Installation

  1. Install the package via Composer:

    composer require mattitjaab/laravel-plausible-proxy
  2. Publish the configuration file:

    php artisan vendor:publish --tag=plausible-proxy-config
  3. 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.