Reporting

Stats, active visitors, pageviews, and metrics

Reporting

All reporting methods accept an optional website id (falling back to config('oi-laravel-umami.website_id')), an $options array, and a $fresh flag to bypass the cache.

Date options

Reporting endpoints are scoped to a time range. Pass startAt / endAt as Carbon instances, DateTimeInterface, date strings, or epoch milliseconds — they are normalized to milliseconds for you. When omitted, the range defaults to the last 7 days.

php
use Illuminate\Support\Carbon;

Umami::stats(options: [
    'startAt' => Carbon::now()->subMonth(),
    'endAt' => Carbon::now(),
    'unit' => 'day',      // hour | day | month
    'timezone' => 'Europe/Paris',
]);

Summary stats

php
$stats = Umami::stats(); // WebsiteStatsData

$stats->pageviews->value;  // int
$stats->pageviews->prev;   // ?int (previous period)
$stats->visitors->value;
$stats->visits->value;
$stats->bounces->value;
$stats->totaltime->value;

Active visitors

php
Umami::activeVisitors()->visitors; // int

Pageviews & sessions time series

php
$series = Umami::pageviews(); // PageviewsData

foreach ($series->pageviews as $point) {
    $point->x; // timestamp
    $point->y; // count
}

$series->sessions; // DataPointData[]

Metrics

Aggregated breakdown by dimension. type defaults to url; other values include referrer, browser, os, device, country, region, city, event.

php
$topPages = Umami::metrics(options: ['type' => 'url']); // Collection<MetricData>

$topPages->first()->x; // "/pricing"
$topPages->first()->y; // 1240

Bypassing the cache

php
Umami::stats(fresh: true);
Project under MIT License.
Design by