Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Visitor Laravel Package

shetabit/visitor

Track and log Laravel visitor info (IP, browser, device, platform, languages, user agent) via request helper, and attach visit logs to models with a Visitable trait. Includes online user detection and visit counting/uniques by IP or user.

View on GitHub
Deep Wiki
Context7

a laravel package to work with visitors and retrieve their informations

Frequently asked questions about Visitor
How do I install and set up shetabit/visitor in Laravel 11+?
Run `composer require shetabit/visitor`, publish migrations with `php artisan vendor:publish`, then execute `php artisan migrate`. Laravel 5.5+ auto-registers the service provider, so no manual provider/alias setup is needed unless you’re on an older version.
Can I track visits for specific models only (e.g., only Posts or Products)?
Yes. Use the `Visitable` trait on targeted models (e.g., `Post` or `Product`) to enable visit logging only for those. The package won’t affect models without the trait, keeping your database lean.
Does shetabit/visitor support Laravel 13’s new features like app models or first-party auth?
The package is fully compatible with Laravel 13, including first-party auth. Use `visitor()->setVisitor($user)` to link visits to authenticated users, and it works seamlessly with Laravel’s new app models.
How do I exclude sensitive routes (e.g., /password/reset) from visit tracking?
Add the `LogVisits` middleware to your `$routeMiddleware` in `app/Http/Kernel.php`, then exclude routes by prefixing them with `middleware('exclude.visits')`. The package includes built-in GDPR/CCPA controls for IP hashing.
Will this package slow down my high-traffic Laravel app (e.g., 10K+ concurrent users)?
For high traffic, use the `LogVisits` middleware selectively (e.g., exclude API routes) or queue visit logs with Laravel Queues. The package avoids WebSocket overhead by using lightweight session-based online detection, but test under load with your DB setup.
How accurate is the device/browser detection, and can I customize it?
Detection uses the `mobile-detect` library, which covers 99% of cases but may misclassify custom user agents. For advanced needs, extend the `Visitor` class or integrate third-party services like WURFL. The package supports custom drivers for GeoIP too.
Can I count unique visitors per model (e.g., unique IPs or users who viewed a Post)?
Yes. Use `$model->visitLogs()->distinct('ip')->count('ip')` for unique IPs or `$model->visitLogs()->visitor()->count()` for unique users. The `visits()` relation also lets you fetch all visit logs for a model.
Does shetabit/visitor work with Laravel’s first-party caching (e.g., Redis) for online user detection?
Online user detection relies on sessions by default. For distributed setups, combine it with Redis caching for session storage. The package doesn’t enforce caching, so you can manually optimize session handling for scalability.
How do I archive or purge old visit logs to avoid database bloat?
Use Laravel’s `softDeletes` or implement a TTL (time-to-live) policy with Laravel Horizon. The package doesn’t include built-in archiving, but you can schedule a job to delete logs older than X days via `VisitLog::where('created_at', '<=', now()->subDays(30))->delete()`.
Are there alternatives to shetabit/visitor for Laravel visitor tracking?
Alternatives include `spatie/analytics` (for event-based tracking) or `laravel-analytics` (for Google Analytics integration). However, `shetabit/visitor` stands out for its model-level tracking (via `Visitable`), real-time online detection, and GDPR-ready IP hashing without external APIs.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata