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

Laravel visitor

Frequently asked questions about Visitor
How do I install and set up shetabit/visitor in Laravel?
Run `composer require shetabit/visitor`, publish migrations with `php artisan vendor:publish`, then execute `php artisan migrate`. No manual provider/alias setup is needed for Laravel 5.5+. Verify installation by calling `visitor()->browser()` in a controller.
Can I track visits for specific models (e.g., BlogPost, Product)?
Yes. Use the `Visitable` trait on your model and call `$model->createVisitLog()` or `visitor()->visit($model)`. Visit logs are stored as a polymorphic relation, so you can query them via `$model->visitLogs`.
How does shetabit/visitor handle performance for high-traffic sites?
The package includes middleware to log visits, which may impact performance at scale. Mitigate this by excluding routes (e.g., API endpoints) in middleware config or by queuing visit logs using Laravel queues. Test with your expected request volume.
Does shetabit/visitor support Laravel 11+ and PHP 8.4?
Yes, the package is actively maintained for Laravel 11–13 and requires PHP 8.4+. Check the [GitHub releases](https://github.com/shetabit/visitor/releases) for version-specific compatibility notes. Downgrade options exist for older Laravel versions.
How do I count unique visitors for a model or globally?
Use `$model->visitLogs()->distinct('ip')->count('ip')` for IP-based uniqueness or `$model->visitLogs()->visitor()->count()` for authenticated user uniqueness. For global unique visitors, query the `visitors` table with `distinct('ip')`.
Can I detect if a user is online in real-time?
Yes. Use `visitor()->isOnline()` to check if the current visitor is active. For authenticated users, set the visitor with `visitor()->setVisitor($user)` before checking. Online status is determined by recent activity (configurable via middleware).
What data does shetabit/visitor collect by default?
The package captures browser, device, platform, IP, languages, and user agent via UAParser. Optional GeoIP enrichment (v4.5.0+) adds location data if configured. All data is stored in the `visits` and `visitors` tables created by migrations.
How do I exclude certain routes from visit logging?
Configure the `LogVisits` middleware in `app/Http/Kernel.php` under `$routeMiddleware` to exclude routes. For example, add `'except' => ['api/*', 'admin/*']` to the middleware options. This reduces unnecessary database writes.
Are there alternatives to shetabit/visitor for Laravel analytics?
Alternatives include `spatie/analytics` (for event-based tracking), `laravel-analytics` (Google Analytics wrapper), or `laravel-visitor` (simpler but less feature-rich). Compare based on needs: shetabit/visitor excels in model-specific visit logging and online detection.
How do I handle GDPR compliance with visitor IP storage?
Anonymize or hash IPs before storage (e.g., using Laravel’s `Hash::make()`). Configure the package to exclude sensitive data from logs or implement automatic purging via model observers. Review your privacy policy to ensure compliance with data retention laws.
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope