LaravelPackages.net
Acme Inc.
Toggle sidebar
roundly-consulting/plausible-for-laravel

Plausible Analytics API client for Laravel

6
0
1.1.1
About roundly-consulting/plausible-for-laravel

roundly-consulting/plausible-for-laravel is a Laravel package for plausible analytics api client for laravel. It currently has 0 GitHub stars and 6 downloads on Packagist (latest version 1.1.1). Install it with composer require roundly-consulting/plausible-for-laravel. Discover more Laravel packages by roundly-consulting or browse all Laravel packages to compare alternatives.

Last updated

Plausible for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

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.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

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

Comments