fomvasss / laravel-visits
Self-hosted, first-party analytics platform for Laravel: visitor/session/event tracking, geo/device/bot detection, campaign attribution, custom conversions tied to your own Eloquent models, rollup analytics, dashboard
Requires
- php: ^8.3
- illuminate/contracts: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/events: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/queue: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- matomo/device-detector: ^6.1
- stevebauman/location: ^7.6
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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 with a live activity map — all in your own database.
- Visitor → Session → Event — durable identity, browsing sessions, page views and custom actions instead of one flat table
- Async-first — the request only resolves the visitor id; geo, device detection and writes run in a queued job
- Three entry points — automatic page views (middleware), a JSON endpoint for the JS beacon and mobile apps,
Visits::track()from PHP - Identity — cookie, client-supplied
X-Visitor-Id, reconnection of logged-in users on Bearer-token APIs, merge on login orVisits::identify() - Attribution — UTM/
reffirst touch and last touch, ad click IDs, search keywords - Conversions on your models —
Visits::track('order.placed', $order)and read it back from$order - Dashboard — Overview with a session map, Campaigns, Sessions, Visitors, Live map, Whoami
- Events for every visit, conversion, new visitor, new session and identified user
Requirements
- PHP ^8.3
- Laravel ^12 | ^13
- A queue worker and the scheduler
Installation
composer require fomvasss/laravel-visits php artisan migrate php artisan vendor:publish --tag=visits-config # optional php artisan vendor:publish --tag=visits-assets # optional, JS beacon
Security: the dashboard at
/visitsis open to anyone by default. Setdashboard.middlewareto e.g.['web', 'auth']before deploying.
Quick start
Every GET request through the web middleware group is now tracked; the dashboard is at /visits.
use Fomvasss\Visits\Concerns\HasVisits; class Order extends Model { use HasVisits; }
use Fomvasss\Visits\Facades\Visits; Visits::track('order.placed', $order, ['amount' => $order->total]); // payment webhook: no cookie, take the visitor from the earlier event Visits::track('order.paid', $order, inheritFrom: 'order.placed'); $order->latestVisitEvent('order.placed')->first()?->session->utm_source;
<script src="/vendor/visits/visits.js"></script> <script> Visits.track('newsletter.subscribed', { plan: 'pro' }); </script>
Documentation
Online: https://fomvasss.github.io/laravel-visits/ — the same pages as in docs/.
- Installation · Configuration
- How tracking works · Page views · Custom events · JS beacon
- Visitor identity · Reading data back · Campaign attribution · Geo & device
- Consent · Custom models & multi-tenancy · Dashboard · Whoami · Rollups & retention
- Guides: Production checklist · Client integration · Security · When to use · Architecture
- Reference: Facade · Models · Database · Routes · JavaScript · Events · Commands · Contracts
- Upgrading · Changelog
Testing
composer test
License
MIT — see LICENSE.
Support
If this package is useful to you, consider supporting its development:
USDT TRC20:
THLgp6DxiAtbNHvgnKV56vk1L38UuUagKf
