Download the PHP package tallesairan/laravel-plausible without Composer
On this page you can find all versions of the php package tallesairan/laravel-plausible. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tallesairan/laravel-plausible
More information about tallesairan/laravel-plausible
Files in tallesairan/laravel-plausible
Package laravel-plausible
Short Description A laravel package for interacting with plausible analytics api.
License MIT
Homepage https://github.com/tallesairan/laravel-plausible
Informations about the package laravel-plausible
Plausible Analytics for Laravel 10+
This package was originally created by @njoguamos - njoguamos/laravel-plausible
I had to make this adaptation because the original project only supports Plausible.io and not self-hosted analytics, I made a change so that the base address of the plausible can be manipulated both by configuration and by method, so we can manage several self-hosted Plausible in a single Apis system
Plausible is intuitive, lightweight and open source web analytics. Plausible has no cookies and fully compliant with GDPR, CCPA and PECR.
Plausible Self Hosting Docs Plausible Analytics is designed to be self-hosted through Docker. You don't have to be a Docker expert to launch your own instance of Plausible Analytics. You should have a basic understanding of the command-line and networking to successfully set up your own instance of Plausible Analytics.
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.
Optional baseUrl or siteId over facade
Develop these methods to help manage multiple plausible self-hosted remotely
default url base is "https://plausible.io" to ensure the operation enter the url without the slash at the end
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.
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
illuminate/support Version ^10.0
sammyjo20/saloon-cache-plugin Version ^2.0
sammyjo20/saloon-laravel Version ^2.0
spatie/laravel-package-tools Version ^1.14.0