Download the PHP package njoguamos/laravel-plausible without Composer
On this page you can find all versions of the php package njoguamos/laravel-plausible. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-plausible
Plausible Analytics for Laravel 10+
Plausible is intuitive, lightweight and open source web analytics. Plausible has no cookies and fully compliant with GDPR, CCPA and PECR.
Installation
You can install the package via composer:
You can initialise the package with:
Install command will publish the config file.
Ensure that you have updated your application .env
with credentials from Plausible i.e.
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
1. Getting Realtime Visitors
To get the current visitors on your default site, run a request as follows.
The response in a single digit number
If you prefer using facades, then you can do as follows.
2. Getting Aggregates
To get the aggregates, run a request as follows.
[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
A successful response will be a json. Example;
Aggregates parameters explained expand to view more details
.
Period - string, optional
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
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
`compare` defaults to `true`, meaning that the percent difference with the previous period for each metric will be calculated.Filters - array, optional
Your filters must be properly formed as per [plausible instructions](https://plausible.io/docs/stats-api#filtering). Filters defaults to `null`.Date - string, optional
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
To get the timeseries data over a certain time period, run a request as follows.
A successful response will be a json. Example;
Timeseries parameters explained expand to view more details
.
Period - string, optional
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
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
Your filters must be properly formed as per [plausible instructions](https://plausible.io/docs/stats-api#filtering). Filters defaults to `null`.Interval - string, optional
Interval can only be either `month` or `date`. When not provided, it defaults to date.Date - string, optional
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
To get a breakdown of your stats by some property, run a request as follows.
The response in a single digit number
Breakdown parameters explained expand to view more details
.
Property - string, optional
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
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
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
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
The results limit. It must be between `1` and `1000`. When not provided, limit defaults to `100`.Page - int, optional
Page for the results. When not provided, page defaults to `1`.Filters - string, optional
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
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.
If for some reason you don't want to cache response, you can turn off caching entirely by adding the following env variable.
Testing
Info To test this package, run the following command.
Changelog
Please see releases for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Njogu Amos
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-plausible with dependencies
guzzlehttp/guzzle Version ^7.5
illuminate/contracts Version ^10.0 | ^11.0
saloonphp/cache-plugin Version ^3.0
saloonphp/laravel-plugin Version ^3.0
spatie/laravel-package-tools Version ^1.16