PHPackages                             ozankurt/tracker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ozankurt/tracker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ozankurt/tracker
================

A modern, privacy-first Laravel visitor analytics package.

1.2.0(1mo ago)07[3 PRs](https://github.com/OzanKurt/tracker/pulls)MITPHPPHP ^8.3CI passing

Since Apr 10Pushed 4w agoCompare

[ Source](https://github.com/OzanKurt/tracker)[ Packagist](https://packagist.org/packages/ozankurt/tracker)[ RSS](/packages/ozankurt-tracker/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (16)Versions (13)Used By (0)

ozankurt/tracker
================

[](#ozankurttracker)

Modern, privacy-first Laravel visitor analytics.

[![PHP](https://camo.githubusercontent.com/ef0054230522e542bc1f908ac005c6c75888dea255bac910f9015e12095e31d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c7565)](https://php.net)[![Laravel](https://camo.githubusercontent.com/e80343355eaae9bc36e27423c4190e7ef89afa5b0dc5d404a827a313db51419c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531322d726564)](https://laravel.com)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

Successor to `pragmarx/tracker`, rewritten from scratch for Laravel 12 and PHP 8.3.

What it tracks
--------------

[](#what-it-tracks)

- **Sessions** (per-visitor, tied to a long-lived cookie)
- **Page views** (every route hit, with route name and params)
- **Users** (when authenticated)
- **Devices, browsers, operating systems, languages**
- **Geo-IP** (country, city, coordinates — via pluggable providers)
- **Referers** (organic search, social, direct, with search terms when available)
- **Custom events** (`Tracker::logEvent('signup.completed', ['plan' => 'pro'])`)

What it doesn't track
---------------------

[](#what-it-doesnt-track)

- SQL queries, exceptions, system classes — use Telescope / Sentry / Flare
- Anything when the user has set `DNT: 1` or the opt-out cookie
- Bots (configurable — defaults to dropping crawlers)

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 12+
- MySQL 8+, Postgres 16+, or SQLite

Installation
------------

[](#installation)

```
composer require ozankurt/tracker
```

The package auto-registers via Laravel's service provider discovery.

Publish the config and run migrations:

```
php artisan vendor:publish --tag=tracker-config
php artisan vendor:publish --tag=tracker-migrations
php artisan migrate
```

Register the middleware in your route groups (or globally in `bootstrap/app.php`):

```
use OzanKurt\Tracker\Http\Middleware\TrackRequests;

// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [TrackRequests::class]);
})
```

Quick usage
-----------

[](#quick-usage)

```
use OzanKurt\Tracker\Facades\Tracker;

// Current visitor's session
$session = Tracker::currentSession();

// Log a custom event
Tracker::logEvent('signup.completed', ['plan' => 'pro']);

// Query recent sessions
$recent = Tracker::sessions(minutes: 60);

// Online users (last 3 minutes of activity)
$online = Tracker::onlineUsers();

// Privacy helpers
Tracker::optOut();      // user clicks "don't track me"
Tracker::optIn();       // undo
Tracker::hasOptedOut(); // cookie check
```

Configuration
-------------

[](#configuration)

See `config/tracker.php` after publishing. Highlights:

KeyDefaultPurpose`enabled``true`Global kill switch`dispatcher``queue``queue`, `sync`, or `defer``geoip.driver``null``null`, `ipapi`, `ipinfo`, `maxmind``privacy.anonymize_ip``true`Zero last octet of IPv4`privacy.respect_dnt``true`Honor `DNT: 1` header`privacy.drop_bots``true`Skip crawler requests`privacy.retention_days``90`Auto-purge old sessions`cookie.lifetime_days``365`Visitor cookie lifetime`routes.ignore``[tracker/*, telescope/*, ...]`Path glob patterns to skipDispatchers
-----------

[](#dispatchers)

- **`queue`** (default) — middleware pushes a `ProcessTrackerPayload` job; processing happens in a queue worker. ~1ms overhead per request.
- **`sync`** — processing runs inline during the request. Useful in tests.
- **`defer`** — processing runs in the middleware's `terminate()` after the response is sent. No queue worker needed; good for Laravel Octane.

Geo-IP providers
----------------

[](#geo-ip-providers)

All providers are optional. Install the one you want and set `TRACKER_GEOIP_DRIVER`:

- **`null`** (default) — no geo lookup
- **`ipapi`** — uses `ip-api.com` (free tier, no key)
- **`ipinfo`** — uses `ipinfo.io` (set `IPINFO_TOKEN`)
- **`maxmind`** — uses MaxMind GeoLite2 (offline). Requires `composer require geoip2/geoip2` and a `GeoLite2-City.mmdb` file at `storage/app/geoip/GeoLite2-City.mmdb`

Lookups are cached in `tracker_geoip_cache` for 30 days by default.

Retention purge
---------------

[](#retention-purge)

Sessions older than `privacy.retention_days` can be pruned via:

```
php artisan tracker:prune
```

Schedule it in `routes/console.php`:

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('tracker:prune')->daily();
```

Dashboard
---------

[](#dashboard)

An admin dashboard ships in a companion release. For now, the read API is fully available via the `Tracker` facade and `OzanKurt\Tracker\Stats\TrackerStats`:

```
use OzanKurt\Tracker\Stats\TrackerStats;

$stats = app(TrackerStats::class);

$stats->uniqueVisitors(now()->subDay());
$stats->topPages(now()->subDay(), limit: 10);
$stats->topCountries(now()->subDay());
$stats->topBrowsers(now()->subDay());
$stats->topDevices(now()->subDay());
$stats->topReferers(now()->subDay());
$stats->sessionsOverTime(now()->subDay(), interval: 'hour');
$stats->pageViewsOverTime(now()->subDay(), interval: 'hour');
```

When the dashboard lands, protect it by defining a gate in your `AuthServiceProvider`:

```
Gate::define('viewTracker', function ($user) {
    return $user?->is_admin === true;
});
```

Testing
-------

[](#testing)

```
composer install
./vendor/bin/pest
./vendor/bin/phpstan analyse
./vendor/bin/pint --test
```

License
-------

[](#license)

MIT © Ozan Kurt

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

6

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c24006c03ba24fcb1c65905a009600b34e17d532add4a381075a2d7379cf4b94?d=identicon)[OzanKurt](/maintainers/OzanKurt)

---

Top Contributors

[![OzanKurt](https://avatars.githubusercontent.com/u/8682003?v=4)](https://github.com/OzanKurt "OzanKurt (89 commits)")

---

Tags

laravelgeoipvisitoranalyticsprivacytracker

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ozankurt-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/ozankurt-tracker/health.svg)](https://phpackages.com/packages/ozankurt-tracker)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.3k6.1M68](/packages/spatie-laravel-analytics)[firefly-iii/data-importer

Firefly III Data Import Tool.

8055.8k](/packages/firefly-iii-data-importer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
