PHPackages                             njoguamos/laravel-plausible - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. njoguamos/laravel-plausible

ActiveLibrary[API Development](/categories/api)

njoguamos/laravel-plausible
===========================

A laravel package for interacting with plausible analytics api.

v3.0.0(1mo ago)208.8k↓18.2%4[2 issues](https://github.com/njoguamos/laravel-plausible/issues)MITPHPPHP ^8.3 | ^8.4 | ^8.5CI passing

Since Apr 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/njoguamos/laravel-plausible)[ Packagist](https://packagist.org/packages/njoguamos/laravel-plausible)[ Docs](https://github.com/njoguamos/laravel-plausible)[ RSS](/packages/njoguamos-laravel-plausible/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (30)Versions (19)Used By (0)

Plausible Analytics for Laravel 11+
===================================

[](#plausible-analytics-for-laravel-11)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c7455617b5760ba46747e79d075f6c44af9ffc876c5b108be6ac605e00cb5fb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6a6f6775616d6f732f6c61726176656c2d706c61757369626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/njoguamos/laravel-plausible)[![Total Downloads](https://camo.githubusercontent.com/d273ce36fc8b71b644c0b0413411e92bcf4838877c45f0e54690e9f369bbd358/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6a6f6775616d6f732f6c61726176656c2d706c61757369626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/njoguamos/laravel-plausible)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8d46ce5119c42701d2026574bb71c7f2bbfa65186b3ada6916e814c777ecc1d6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6a6f6775616d6f732f6c61726176656c2d706c61757369626c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/njoguamos/laravel-plausible/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Workflow Status](https://camo.githubusercontent.com/ce83551a9eecedce55f045f9b9c6bb9f809b3885e3be959e9997e88d8b196237/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6a6f6775616d6f732f6c61726176656c2d706c61757369626c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6c6162656c3d636f64652532307374796c65)](https://camo.githubusercontent.com/ce83551a9eecedce55f045f9b9c6bb9f809b3885e3be959e9997e88d8b196237/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6a6f6775616d6f732f6c61726176656c2d706c61757369626c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6c6162656c3d636f64652532307374796c65)

[Plausible](https://plausible.io/) is intuitive, lightweight and open source web analytics. Plausible has no cookies and fully compliant with GDPR, CCPA and PECR.

Installation
------------

[](#installation)

VersionSupported Laravel1.x10.x, 11.x2.x11.x, 12.x3.x12.x, 13.xYou can install the package via composer:

```
composer require njoguamos/laravel-plausible
```

You can initialise the package with:

```
php artisan plausible:install
```

Install command will publish the [config file](/config/plausible.php).

Ensure that you have updated your application `.env` with credentials from [Plausible](https://plausible.io/docs/stats-api) i.e.

```
#.env file

PLAUSIBLE_SITE_ID=
PLAUSIBLE_API_KEY=
#PLAUSIBLE_BASE_URL=  *Note* If you are using a self-hosted version of plausible, ensure that you define `PLAUSIBLE_BASE_URL` to point to your custom domain.

Usage
-----

[](#usage)

### 1. Getting Realtime Visitors

[](#1-getting-realtime-visitors)

To get the current visitors on your default site, run a request as follows.

```
use NjoguAmos\Plausible\Facades\Plausible;

$visitors = Plausible::realtime();
```

The response in a single digit number

```
12
```

If you prefer using facades, then you can do as follows.

```
use NjoguAmos\Plausible\Facades\Plausible;

$all = Plausible::aggregates();
```

### 2. Getting Aggregates

[](#2-getting-aggregates)

To get the aggregates, run a request as follows.

```
use NjoguAmos\Plausible\Facades\Plausible;

// Simple with default
$aggregates = Plausible::aggregates();

// Or with optional custom parameters
$aggregates = Plausible::aggregates(
    period: 'custom',
    metrics: ['visitors', 'visits', 'pageviews'],
    filters: ['event:page==/blog**'],
    date: '2023-01-01,2023-01-31',
    withImported: true
);
```

> \[Note\] Filtering by imported data is limited. The general rule is that you cannot filter by two different properties at the same time. Learn more from [Plausible Imported stats documentation](https://plausible.io/docs/stats-api#imported-stats)

A successful response will be a json. Example;

```
{
    "bounce_rate": {
        "change": 4,
        "value": 71
    },
    "events": {
        "change": -24,
        "value": 1166
    },
    "pageviews": {
        "change": -24,
        "value": 1166
    },
    "views_per_visit": {
        "change": -26,
        "value": 3
    },
    "visit_duration": {
        "change": -37,
        "value": 132
    },
    "visitors": {
        "change": 1,
        "value": 360
    },
    "visits": {
        "change": 3,
        "value": 389
    }
}
```

#### Aggregates parameters explained `expand to view more details`.

[](#aggregates-parameters-explained-expand-to-view-more-details)

Period - string, optional```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::aggregates(period: '7d')
```

The `period` MUST be either of the allowed ones i.e `12mo`,`6mo`,`month`,`0d`,`7d`,`day`, or `custom`. If not provided, period will default to `30d`;

 Metrics - array, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::aggregates(metrics: ['visitors', 'visits'])
```

The `metrics` must contain either of the allowed ones i.e `visitors`,`visits`,`pageviews`,`views_per_visit`,`bounce_rate`,`visit_duration`, or `events`. If not provided, all metrics will be included.

 Compare - boolean, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::aggregates(compare: false )
```

`compare` defaults to `true`, meaning that the percent difference with the previous period for each metric will be calculated.

 Filters - array, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::aggregates(filters: ['event:page==/blog**', 'visit:country==KE|DE'])
```

Your filters must be properly formed as per [plausible instructions](https://plausible.io/docs/stats-api#filtering). Filters defaults to `null`.

 Date - string, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::aggregates(period: 'custom', date: '2023-01-01,2023-01-31')
```

Date in `Y-m-d` format. Individual date e.g `2023-01-04` or a range `2023-01-01,2023-01-31`. When not provided, date defaults to `current date`.

> **Info**You must include `period: 'custom'` when you provide a date range.

### 3. Getting Time Series

[](#3-getting-time-series)

To get the timeseries data over a certain time period, run a request as follows.

```
use NjoguAmos\Plausible\Facades\Plausible;

// Simple with default
$aggregates = Plausible::timeSeries();

// Or with optional custom parameters
$aggregates = Plausible::timeSeries(
        period: 'custom',
        metrics: ['visitors', 'visits', 'pageviews', 'views_per_visit', 'bounce_rate', 'visit_duration'],
        filters: ['event:page==/blog**'],
        interval: 'month',
        date: '2023-01-01,2023-01-31'
    );
```

A successful response will be a json. Example;

```
[
    {
        "bounce_rate": 17,
        "date": "2023-01-01",
        "pageviews": 60,
        "views_per_visit": 19,
        "visit_duration": 525,
        "visitors": 6,
        "visits": 6
    },
    {
        "bounce_rate": 12,
        "date": "2023-01-02",
        "pageviews": 22,
        "views_per_visit": 4,
        "visit_duration": 149,
        "visitors": 6,
        "visits": 8
    },
    {
        "bounce_rate": 57,
        "date": "2023-01-03",
        "pageviews": 9,
        "views_per_visit": 2.57,
        "visit_duration": 48,
        "visitors": 7,
        "visits": 7
    },
    {
        "bounce_rate": 71,
        "date": "2023-01-04",
        "pageviews": 48,
        "views_per_visit": 8.43,
        "visit_duration": 301,
        "visitors": 7,
        "visits": 7
    }
]
```

#### Timeseries parameters explained `expand to view more details`.

[](#timeseries-parameters-explained-expand-to-view-more-details)

Period - string, optional```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::timeSeries(period: '6mo')
```

The `period` MUST be either of the allowed ones i.e `12mo`,`6mo`,`month`,`0d`,`7d`,`day`, or `custom`. If not provided, period will default to `30d`;

 Metrics - array, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::timeSeries(metrics: ['visits', 'pageviews', 'views_per_visit'])
```

The `metrics` must contain either of the allowed ones i.e `visitors`,`visits`,`pageviews`,`views_per_visit`,`bounce_rate`,`visit_duration`, or `events`. If not provided, all metrics will be included.

 Filters - array, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::timeSeries(filters: ['event:page==/blog**', 'visit:browser==Firefox'])
```

Your filters must be properly formed as per [plausible instructions](https://plausible.io/docs/stats-api#filtering). Filters defaults to `null`.

 Interval - string, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::timeSeries(interval: 'month')
```

Interval can only be either `month` or `date`. When not provided, it defaults to date.

 Date - string, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::timeSeries(period: 'custom', date: '2023-01-01,2023-01-31')
```

Date in `Y-m-d` format. Individual date e.g `2023-01-04` or a range `2023-01-01,2023-01-31`. When not provided, date defaults to `current date`.

> **Info**You must include `period: 'custom'` when you provide a date range.

### 4. Getting Breakdowns

[](#4-getting-breakdowns)

To get a breakdown of your stats by some property, run a request as follows.

```
use \NjoguAmos\Plausible\Facades\Plausible;

// Simple with defaults
$visitors = Plausible::breakdown();

// With optional parameters
$aggregates = Plausible::breakdown(
        property: 'event:page',
        period: '12mo',
        metrics: ['visitors', 'visits', 'pageviews'],
        filters: 'event:page==/blog**',
        limit: 500
    );
```

The response in a single digit number

```
[
    {
        "bounce_rate": 71,
        "page": "/",
        "pageviews": 146,
        "visit_duration": 126,
        "visitors": 87,
        "visits": 77
    },
    {
        "bounce_rate": 54,
        "page": "/articles",
        "pageviews": 179,
        "visit_duration": 206,
        "visitors": 71,
        "visits": 50
    },
    {
        "bounce_rate": 81,
        "page": "/blog/about-laravel-plausible",
        "pageviews": 42,
        "visit_duration": 27,
        "visitors": 35,
        "visits": 37
    },
    {
        "bounce_rate": 52,
        "page": "/pricing",
        "pageviews": 72,
        "visit_duration": 147,
        "visitors": 31,
        "visits": 27
    },
    {
        "bounce_rate": 76,
        "page": "/aquatadas",
        "pageviews": 22,
        "visit_duration": 82,
        "visitors": 21,
        "visits": 21
    }
]
```

#### Breakdown parameters explained `expand to view more details`.

[](#breakdown-parameters-explained-expand-to-view-more-details)

Property - string, optional```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::breakdown(property: '6mo')
```

The `property` MUST be either of the allowed ones i.e. `visitors`, `visits`, `pageviews`, `bounce_rate`, or `visit_duration`. If not provided, period will default to all allowed;

Period - string, optional```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::breakdown(period: '6mo')
```

The `period` MUST be either of the allowed ones i.e `12mo`,`6mo`,`month`,`0d`,`7d`,`day`, or `custom`. If not provided, period will default to `30d`;

 Date - string, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::breakdown(date: '2023-01-01')
```

Date in `Y-m-d` format.

> **Info**`period: 'custom'` is not supported. `date: '2023-01-01,2023-02-02' is not supported.

 Metrics - array, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::breakdown(metrics: ['visits', 'pageviews', 'views_per_visit'])
```

The `metrics` must contain either of the allowed ones i.e `visitors`,`visits`,`pageviews`,`views_per_visit`,`bounce_rate`,`visit_duration`, or `events`. If not provided, all metrics will be included.

 Limit - int, optional ```
use NjoguAmos\Plausible\Facades\Plausible;;

$aggregates = Plausible::breakdown(limit: 200)
```

The results limit. It must be between `1` and `1000`. When not provided, limit defaults to `100`.

 Page - int, optional ```
use NjoguAmos\Plausible\Facades\Plausible;;

$aggregates = Plausible::breakdown(page: 2)
```

Page for the results. When not provided, page defaults to `1`.

 Filters - string, optional ```
use NjoguAmos\Plausible\Facades\Plausible;

$aggregates = Plausible::breakdown(filters: 'event:page==/blog**')
```

Your filters must be properly formed as per [plausible instructions](https://plausible.io/docs/stats-api#filtering). Filters defaults to `null`.

> **Info**Multiple filters are not supported.

### 5. Caching Response

[](#5-caching-response)

To increased performance of your application and reduce reliance to plausible api, all requests are cached for 3 minutes. You can specify cache duration (in seconds) and driver using the following env variables.

```
PLAUSIBLE_CACHE_DURATION=300
PLAUSIBLE_CACHE_DRIVER=redis
```

If for some reason you don't want to cache response, you can turn off caching entirely by adding the following env variable.

```
PLAUSIBLE_CACHE=false
```

Testing
-------

[](#testing)

> **Info**To test this package, run the following command.

```
composer test
```

Changelog
---------

[](#changelog)

Please see [releases](https://github.com/njoguamos/laravel-plausible/releases) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Njogu Amos](https://github.com/njoguamos)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 83.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~134 days

Total

17

Last Release

54d ago

Major Versions

v0.1.0 → v1.0.02023-04-06

v1.6.1 → v2.0.02025-03-17

v2.0.2 → v3.0.02026-03-25

PHP version history (4 changes)v0.1.0PHP ^8.1 | ^8.2

v1.4.0PHP ^8.1 | ^8.2 | ^8.3

v2.0.0PHP ^8.2 | ^8.3 | ^8.4

v3.0.0PHP ^8.3 | ^8.4 | ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/1262b428518ef976f4268074e0b9e9280ec9af765aee553112bea64401beed8f?d=identicon)[njoguamos](/maintainers/njoguamos)

---

Top Contributors

[![njoguamos](https://avatars.githubusercontent.com/u/29255728?v=4)](https://github.com/njoguamos "njoguamos (61 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![Tschucki](https://avatars.githubusercontent.com/u/43211841?v=4)](https://github.com/Tschucki "Tschucki (2 commits)")[![dudelisius](https://avatars.githubusercontent.com/u/394451?v=4)](https://github.com/dudelisius "dudelisius (1 commits)")[![RickDeGraaf1](https://avatars.githubusercontent.com/u/144659437?v=4)](https://github.com/RickDeGraaf1 "RickDeGraaf1 (1 commits)")

---

Tags

frameworklaravelphpplausibleplausible-analyticslaravelanalyticsplausiblenjoguamos

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/njoguamos-laravel-plausible/health.svg)

```
[![Health](https://phpackages.com/badges/njoguamos-laravel-plausible/health.svg)](https://phpackages.com/packages/njoguamos-laravel-plausible)
```

###  Alternatives

[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[codebar-ag/laravel-zammad

Zammad integration with Laravel

106.1k](/packages/codebar-ag-laravel-zammad)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[njoguamos/laravel-turnstile

A laravel wrapper for https://developers.cloudflare.com/turnstile/

2315.9k2](/packages/njoguamos-laravel-turnstile)[xelon-ag/vmware-php-client

PHP API Client for VmWare

114.3k](/packages/xelon-ag-vmware-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
