### Install via Composer Source: https://github.com/roundly-consulting/plausible-for-laravel/blob/main/README.md Install the package using Composer. Requires PHP 8.4 with ext-bcmath, Laravel 12 or 13, and a Plausible account. ```bash composer require roundly-consulting/plausible-for-laravel ``` -------------------------------- ### Query stats with fluent builder Source: https://github.com/roundly-consulting/plausible-for-laravel/blob/main/README.md Use the Plausible facade to query aggregate stats and breakdowns. The example shows fetching visitors and pageviews for the last 30 days with comparison, and a breakdown by visit source for the last 7 days. ```php 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 ``` -------------------------------- ### Capture custom event server-side Source: https://github.com/roundly-consulting/plausible-for-laravel/blob/main/README.md Capture a conversion event server-side. The visitor is taken from the request and the site from the PLAUSIBLE_SITE environment variable. ```php use RoundlyConsulting\Plausible\DataTransferObjects\Revenue; Plausible::events()->fromRequest(request())->event( 'Signup', url: url('/register'), props: ['plan' => 'pro'], revenue: Revenue::of('49.00', 'EUR'), ); ```