New

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

kilobyteno/laravel-plausible

A simple package for communicating with the Plausible API within Laravel.
5,570 7
Install
composer require kilobyteno/laravel-plausible
Latest Version:1.4.0
PHP:^8.1|^8.2|^8.3|^8.4
Laravel:11 · 12 · 13
Older releases:8 · 9 · 10
License:MIT
Last Updated:Jun 28, 2026
Links: GitHub  ·  Packagist
Maintainer: DanielRTRD

Laravel Plausible

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

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

Installation

You can install the package via composer:

composer require kilobyteno/laravel-plausible

You can publish the config file with:

php artisan vendor:publish --tag="plausible-config"

This is the contents of the published config file:

return [
    'api_url' => env('PLAUSIBLE_API_URL', 'https://plausible.io/api/v1'),
    'api_key' => env('PLAUSIBLE_API_KEY', ''),
];

Usage

use Kilobyteno\LaravelPlausible\Plausible;

// Show the stats for the default period (30d), the period is optional for all methods
$visitors = Plausible::getVisitors($domain->name);

// Show the stats for the last 12 months
$pageviews = Plausible::getPageviews($domain->name, '12mo');

// Get bounce rates for the last 7 days
$bounceRate = Plausible::getBounceRate($domain->name, '7d');

// Get visit duration for the last days
$visitDuration = Plausible::getVisitDuration($domain->name, 'day');

// Get realtime visitors
$realtimeVisitors = Plausible::getRealtimeVisitors($domain->name);

// Add a custom period and metrics
$stats = Plausible::get($domain->name, 'month', ['visitors', 'pageviews']);

$availablePeriods = Plausible::getAllowedPeriods();
// returns: ['12mo', '6mo', 'month', '30d', '7d', 'day']

$allowedMetrics = Plausible::getAllowedMetrics();
// returns: ['visitors', 'pageviews', 'bounce_rate', 'visit_duration', 'visits', 'events']

$allowedProperties = Plausible::getAllowedProperties();
/* 
returns [
    'event:name',
    'event:page',
    'visit:entry_page',
    'visit:exit_page',
    'visit:source',
    'visit:referrer',
    'visit:utm_medium',
    'visit:utm_source',
    'visit:utm_campaign',
    'visit:utm_content',
    'visit:utm_term',
    'visit:device',
    'visit:browser',
    'visit:browser_version',
    'visit:os',
    'visit:os_version',
    'visit:country',
];
*/

Catching exceptions

use Kilobyteno\LaravelPlausible\Exceptions\PlausibleAPIException;

try {
    $visitors = Plausible::getVisitors($domain->name);
} catch (PlausibleAPIException $e) {
    // Handle exception
}

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.

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
njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

10,702 20

Version History

Version Released PHP Laravel License
1.4.0 ^8.1|^8.2|^8.3|^8.4 ^11.0|^12.0|^13.0 MIT
1.3.0 ^8.1|^8.2|^8.3|^8.4 ^11.0|^12.0 MIT
1.2.0 ^8.0|^8.1|^8.2|^8.3 ^8.0|^9.0|^10.0|^11.0 MIT
1.1.0 ^8.0|^8.1|^8.2 ^8.0|^9.0|^10.0 MIT
1.0.0 ^8.0|^8.1 ^8.0|^9.0 MIT