---
title: "Plausible for Laravel — docs | Roundly"
description: "Developer docs for Plausible for Laravel: typed stats queries, server-side events and revenue, pageview tracking, site provisioning and a test fake."
url: https://roundly-consulting.com/open-source/docs/plausible-for-laravel
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

Open source

# Plausible for Laravel

Install

`composer require roundly-consulting/plausible-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/plausible-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/plausible-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

A clean, expressive client for the Plausible Analytics API — Cloud or self-hosted. Read your stats through a fluent, strongly-typed builder, capture server-side events and exact revenue, track pageviews and model events without writing tracking code, and provision sites, goals and shared links from your Laravel app. MIT-licensed and built only on official Laravel components plus four small Roundly companion packages — no third-party analytics SDK.

### What you get

#### Fluent, typed stats

Realtime, aggregate, timeseries and breakdown reads through one fluent builder that returns typed result objects.

#### Stats v2 queries

Dimensions, type-safe where()/orWhere() filters, ordering and pagination against the /api/v2/query endpoint.

#### Server-side events

Capture pageviews and custom events from the backend — synchronously, on the queue, or as a single job batch.

#### Exact revenue

Revenue is a money-for-laravel Money, sent as an exact decimal string. Currencies Plausible can’t convert are refused up front.

#### Tracking without tracking code

A pageview middleware, a Trackable model trait, and the hosted script via @plausibleScript or Plausible::script().

#### Site provisioning

Create, update and delete sites, goals and shared dashboard links from code — built for multi-tenant products.

#### Rate limits & a test fake

Per-surface client-side rate limiting with adaptive 429 backoff, plus a recording Plausible::fake() for your tests.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/installation.md)

Install via Composer, set three env variables and verify the connection with one Artisan command.

#### [Configuration](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/configuration.md)

Every config key, its default and its env variable — instance, default site, HTTP, rate limits, tracking and script.

#### [The Plausible facade](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/client.md)

The Plausible facade: one resource client per API area — stats, events, sites, goals, shared links — plus script, ping and health.

#### [Without the facade](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/without-facade.md)

Skip the facade: inject PlausibleManager or call the plausible() helper — and why there are resource clients instead of actions.

#### [Querying stats](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/stats.md)

Read realtime visitors, aggregates, timeseries and breakdowns through the fluent builder, with typed results and period shortcuts.

#### [Filters](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/filters.md)

Type-safe where()/orWhere() filters for Stats v2, custom-property filters, and the raw v1 string and v2 array forms.

#### [Stats v2 queries](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/query-api.md)

Drive the /api/v2/query endpoint with dimensions, ordering, includes and pagination, and read positional QueryResult rows.

#### [Caching, collections & pagination](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/caching-pagination.md)

Cache any stats read by query signature, turn results into Collections, and walk every breakdown page with cursor() or each().

#### [Explicit request objects](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/explicit-requests.md)

Build AggregateRequest, TimeseriesRequest and BreakdownRequest yourself and get the raw Response or a typed result.

#### [Capturing events](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/events.md)

Send pageviews and custom events server-side — synchronously, on the queue, or as a batch — with the visitor Plausible needs.

#### [Revenue](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/revenue.md)

Attach exact revenue to events as a money-for-laravel Money — decimal strings, no floats, invalid currencies refused up front.

#### [Automatic pageviews](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/pageview-tracking.md)

The plausible.track middleware records server-side pageviews for successful HTML GET responses, after the response is sent.

#### [Model events (Trackable)](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/model-events.md)

Emit Plausible events on Eloquent lifecycle hooks with the Trackable trait — custom props, URL and site per model.

#### [Tracking script](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/tracking-script.md)

Render the official hosted Plausible script with @plausibleScript or <x-plausible-script>, configured from one place.

#### [Sites, goals & shared links](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/sites.md)

Provision Plausible sites, conversion goals and shareable dashboard links from code — typed results, one rate-limit bucket.

#### [Enums](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/enums.md)

Type-safe metrics, periods, intervals, properties, dimensions, operators and goal types, with enums-for-laravel helpers.

#### [Rate limiting](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/rate-limiting.md)

Per-surface client-side rate limits for stats, events and sites, with adaptive 429 backoff, fail-fast and shared budgets.

#### [Health check](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/health-check.md)

Check configuration and API connectivity without throwing — ping(), health() and the plausible:health Artisan command.

#### [Exceptions](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/exceptions.md)

The PlausibleException hierarchy — configuration, visitor, revenue, unsupported-request and rate-limit errors — and how HTTP failures surface.

#### [Testing](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/testing.md)

Swap the client for a recording Plausible::fake() — no real HTTP — and assert on captured events, stats queries and provisioning.

#### [Requirements](https://roundly-consulting.com/open-source/docs/plausible-for-laravel/requirements.md)

PHP 8.4+ with ext-bcmath, Laravel 12 or 13, and a Plausible account — a Stats or Sites API key, or no key just to capture events.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source.md)
