Looking to hire Laravel developers? Try LaraJobs

plausible-for-laravel maintained by roundly-consulting

Description
Plausible Analytics API client for Laravel
Last update
2026/10/03 20:14 (dev-main)
License
Downloads
2

Comments
comments powered by Disqus

Plausible for Laravel

A clean, expressive client for the Plausible Analytics API. Query your stats, capture custom events server-side, and manage sites from your Laravel application through a fluent, strongly-typed API — no manual HTTP plumbing required.

Installation

Requires PHP 8.4 (ext-bcmath), Laravel 12 or 13, and a Plausible account (Cloud or self-hosted).

composer require roundly-consulting/plausible-for-laravel

Set PLAUSIBLE_URL (your Plausible instance, e.g. https://plausible.io), PLAUSIBLE_API_KEY (a Stats API key — event capture needs none) and PLAUSIBLE_SITE (the default site) in .env.

Usage

Read typed stats with the fluent builder:

use RoundlyConsulting\Plausible\Enums\Metric;
use RoundlyConsulting\Plausible\Enums\Property;
use RoundlyConsulting\Plausible\Facades\Plausible;

$result = Plausible::stats()
    ->for('my-site.com')
    ->metrics(Metric::Visitors, Metric::Pageviews)
    ->last30Days()
    ->compare()
    ->aggregate();                              // -> AggregateResult

$result->metric(Metric::Visitors);              // 2001
$result->change(Metric::Visitors);              // 30 — the change vs the previous 30 days

$sources = Plausible::stats()->for('my-site.com')->last7Days()
    ->breakdown(Property::VisitSource)
    ->rows();                                   // list<BreakdownRow>

Capture a conversion server-side — the visitor comes from the request, the site from PLAUSIBLE_SITE:

use RoundlyConsulting\Plausible\DataTransferObjects\Revenue;

Plausible::events()->fromRequest(request())->event(
    'Signup',
    url: url('/register'),
    props: ['plan' => 'pro'],
    revenue: Revenue::of('49.00', 'EUR'),
);

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/plausible-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

License

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