1. Go to this page and download the library: Download njoguamos/laravel-plausible library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
njoguamos / laravel-plausible example snippets
use NjoguAmos\Plausible\Facades\Plausible;
$visitors = Plausible::realtime();
use NjoguAmos\Plausible\Facades\Plausible;
$all = Plausible::aggregates();
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
);
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::aggregates(period: '7d')
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::aggregates(metrics: ['visitors', 'visits'])
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::aggregates(compare: false )
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::aggregates(filters: ['event:page==/blog**', 'visit:country==KE|DE'])
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::aggregates(period: 'custom', date: '2023-01-01,2023-01-31')
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'
);
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::timeSeries(period: '6mo')
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::timeSeries(metrics: ['visits', 'pageviews', 'views_per_visit'])
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::timeSeries(filters: ['event:page==/blog**', 'visit:browser==Firefox'])
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::timeSeries(interval: 'month')
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::timeSeries(period: 'custom', date: '2023-01-01,2023-01-31')
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
);
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::breakdown(property: '6mo')
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::breakdown(period: '6mo')
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::breakdown(date: '2023-01-01')
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::breakdown(metrics: ['visits', 'pageviews', 'views_per_visit'])
use NjoguAmos\Plausible\Facades\Plausible;;
$aggregates = Plausible::breakdown(limit: 200)
use NjoguAmos\Plausible\Facades\Plausible;;
$aggregates = Plausible::breakdown(page: 2)
use NjoguAmos\Plausible\Facades\Plausible;
$aggregates = Plausible::breakdown(filters: 'event:page==/blog**')