pragmarx/tracker
pragmarx/tracker is a Laravel analytics package that records visitors, page views, devices, browsers, referrers, and geo data in your own database. Middleware, a dashboard, and query helpers let you inspect traffic without relying on third-party services.
composer require pragmarx/tracker. As of v4.0.0 the package declares support for PHP >= 7 and Laravel 7 — that is both a floor and, in practice, the ceiling you should assume until a newer release says otherwise. On Laravel 8+ verify (or fork) before committing; on Laravel 6 or older PHP, pin to the 3.x line.config/tracker.php and migrations against what you already have before running php artisan migrate, and re-publish only the files you actually need.config/tracker.php, the published migrations, and the package middleware class. Those three files determine whether tracking is enabled, where data is stored, and what gets recorded.web group or a route group after session/auth middleware. Do not enable it globally on admin, health-check, webhook, or asset routes.use PragmaRX\Tracker\Vendor\Laravel\Models\Session;
$sessions = Session::with(['visitor', 'pageViews.route'])
->latest('started_at')
->limit(20)
->get();
If rows appear with page views, referrers, and visitor data, you have enough to build a simple internal dashboard. Start there rather than trying to replace a full analytics platform.
use PragmaRX\Tracker\Vendor\Laravel\Models\PageView;
use Illuminate\Support\Facades\DB;
$topPages = PageView::query()
->select('route_id', DB::raw('count(*) as views'))
->with('route')
->groupBy('route_id')
->orderByDesc('views')
->limit(10)
->get();
composer.json constraints, or backport schema/service-provider fixes yourself before relying on it.StartSession and auth middleware; otherwise sessions may be anonymous or missing. Laravel 7's web group already handles this, but custom groups do not.config/tracker.php, clear config cache with php artisan config:clear. If the package exposes routes/dashboard pages, also consider route caching behavior and protect those routes with auth/authorization.How can I help you explore Laravel packages today?