Laravel Visits
Self-hosted, first-party analytics for Laravel: visitor, session and page-view tracking, geo/device/bot detection, campaign attribution, conversions tied to your own Eloquent models, daily rollups and a built-in dashboard — all stored in your own database.
The package records three levels of data instead of one flat “visits” table:
Visitor one row per browser/device — durable identity (cookie or client-supplied id) └─ Session one browsing session, closed after inactivity └─ Event a page view or a custom action ("order.placed")- Async-first — the request only resolves the visitor id and dispatches
RecordVisitJob; geo lookup, device/bot detection and all database writes run on the queue - Three entry points — automatic page views (
TrackVisitmiddleware), a JSON endpoint for the JS beacon and mobile apps (POST /visits/collect), andVisits::track()from PHP - Identity — a long-lived cookie, a client-supplied
X-Visitor-Idfor SPAs and mobile apps, automatic reconnection of logged-in users on Bearer-token APIs, merge onLoginorVisits::identify() - Attribution — UTM/
reffirst-touch on the visitor and last-touch on the session, ad click IDs (gclid,fbclid, …), organic search keywords from the referrer - Conversions on your models —
Visits::track('order.placed', $order)writes a polymorphiceventablerelation you can read back from the order - Geo, device, bot detection —
stevebauman/location(HTTP providers or a local MaxMind database) andmatomo/device-detector; bots are recorded but hidden from reads by default - Dashboard — Overview with a session map, Campaigns, Sessions, Visitors, per-session/visitor detail, Live activity map (polling or SSE), Whoami
- Hooks — events for every recorded visit, conversion, new visitor, new session and identified visitor

Quick example
Section titled “Quick example”composer require fomvasss/laravel-visitsphp artisan migrateEvery GET request through the web middleware group is now tracked (a queue worker must be running), and the dashboard is at /visits.
Track a conversion from anywhere in your code:
use Fomvasss\Visits\Facades\Visits;
Visits::track('order.placed', $order, ['amount' => $order->total]);Read it back from the order (the model uses the HasVisits trait):
$event = $order->latestVisitEvent('order.placed')->first();
$event->session->utm_source; // campaign that brought this order$event->session->country_code; // where it was placed fromContents
Section titled “Contents”Getting started
Usage
- How tracking works
- Page views
- Custom events & conversions
- JS beacon
- Visitor identity
- Reading data back
- Campaign attribution
- Geo, device & bot detection
- Consent
- Custom models & multi-tenancy
- Dashboard
- Whoami
- Rollups, sessions & retention
Guides
- Production checklist
- Client integration scenarios
- Security considerations
- When to use this package
- Architecture
Reference