New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

vincentbean/laravel-plausible

Laravel Plausible
75,760 25
Install
composer require vincentbean/laravel-plausible
Latest Version:2.4.0
PHP:^8.3
Laravel:12 · 13
Older releases:8 – 11
License:MIT
Last Updated:Mar 18, 2026
Links: GitHub  ·  Packagist
Maintainer: vincentbean

Laravel Plausible

Tests Coverage Analysis Total downloads

This package provides a blade view with the script tag for plausible and a wrapper to easily send custom events to Plausible.

Installation

You can install the package via composer:

composer require vincentbean/laravel-plausible

You can publish the config file with:

php artisan vendor:publish --provider="VincentBean\Plausible\LaravelPlausibleServiceProvider" --tag="config"

Add the following to your env:

PLAUSIBLE_TRACKING_DOMAIN=DOMAIN_YOU_WANT_TO_TRACK
PLAUSIBLE_DOMAIN=OPTIONAL_IF_SELF_HOSTING

Usage

This package supports both client side and server side tracking.

Client Side Tracking

Include the component in your layout to add the plausible script, with optional tracking extensions.

<x-plausible::tracking />
or
<x-plausible::tracking extensions="hash, outbound-links, etc.." />

Plausible will be available on the window object for sending custom events via Javascript:

plausible('event')

Server Side Tracking

Track pageviews server side using middleware.

Laravel 11:

// bootstrap/app.php
    return Application::configure(basePath: dirname(__DIR__))
        // ...
        ->withMiddleware(function (Middleware $middleware) {
            // Append this middleware to track globally
            $middleware->web(append: [\VincentBean\Plausible\Middleware\TrackPlausiblePageviews::class]);
        })
        // ...

Laravel 10 and earlier versions:

// app/Http/Kernel.php
    'web' => [
        // Add this middleware to the web group to track globally
        \VincentBean\Plausible\Middleware\TrackPlausiblePageviews::class,
    ],

Custom Events

You can trigger custom events on the server.

\VincentBean\Plausible\Events\PlausibleEvent::fire('custom event', ['country' => 'netherlands']);

If firing your event from a queued job or event listener, it might be necessary to pass on the user's ip and user-agent string which are used by Plausible to generate user session ID's.

\VincentBean\Plausible\Events\PlausibleEvent::fire('custom event', ['country' => 'netherlands'], headers: [
    'X-Forwarded-For' => $event->userIp,
    'user-agent' => $event->userAgent
]);

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

c6digital/laravel-plausible

Send server-side events from Laravel to Plausible.

1,654 1
jeffersongoncalves/laravel-plausible

A lightweight Laravel package that seamlessly integrates Plausible Analytics int...

140 2
kilobyteno/laravel-plausible

A simple package for communicating with the Plausible API within Laravel.

5,570 7
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982

Version History

Version Released PHP Laravel License
2.4.0 ^8.3 ^12.0|^13.0 MIT
2.3.1 ^8.2 ^11.0|^12.0 MIT
2.3.0 ^8.2 ^11.0|^12.0 MIT
2.2.0 ^8.0 ^9.0|^10.0|^11.0 MIT
2.1.2 ^8.0 ^9.0|^10.0|^11.0 MIT