jeffersongoncalves / laravel-page-visits
Track page-view visits on any Laravel app's public routes, with device/browser/geo/locale/referer/UTM capture
Package info
github.com/jeffersongoncalves/laravel-page-visits
pkg:composer/jeffersongoncalves/laravel-page-visits
Requires
- php: ^8.2
- illuminate/contracts: ^12.0|^13.0
- jeffersongoncalves/laravel-visitor-fingerprint: ^1.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel Page Visits
Tracks page-view visits on any Laravel app's public GET routes: one row per page hit, capturing
device/browser/GeoIP/locale/referer/UTM safely — anonymized IP, bot flagging, and GDPR export/
erasure — on top of jeffersongoncalves/laravel-visitor-fingerprint
for every fingerprinting primitive.
Installation
You can install the package via composer:
composer require jeffersongoncalves/laravel-page-visits
Publish the config file and run the migration:
php artisan vendor:publish --tag="page-visits-config"
php artisan migrate
Usage
Once installed, the package automatically appends TrackPageVisit to the web middleware group
(disable via page-visits.auto_register_middleware) and every GET request not matched by
page-visits.exclude gets a page_visits row — no further setup required.
use JeffersonGoncalves\LaravelPageVisits\Models\PageVisit; PageVisit::query()->latest('visited_at')->first();
GDPR / LGPD export and erasure
use JeffersonGoncalves\LaravelPageVisits\Compliance\PageVisitPersonalDataService; $service = new PageVisitPersonalDataService; $service->exportForIp($ip); // matching rows as arrays $service->forgetForIp($ip); // nulls ip_hash/ip_anonymized/ip_version/user_agent_hash in place
Configuration
// config/page-visits.php return [ 'table' => 'page_visits', 'track_ip_address' => true, 'track_browser' => true, 'track_browser_version' => true, 'track_operating_system' => true, 'track_operating_system_version' => true, 'track_device_type' => true, 'track_referer_url' => true, 'track_browser_language' => true, 'exclude' => [ 'livewire/update', 'admin/*', 'app/*', 'horizon/*', '_debugbar/*', 'sw.js', 'manifest.json', 'favicon-proxy', 'up', 'og/*', ], 'auto_register_middleware' => true, 'retention_days' => env('PAGE_VISITS_RETENTION_DAYS', 400), 'compliance' => [ 'analytics_only' => env('PAGE_VISITS_ANALYTICS_ONLY', false), ], ];
Every track_* toggle nulls out its own column instead of skipping the row — the visit is always
recorded, just with less detail when a toggle is off. compliance.analytics_only additionally nulls
every PII column (ip_hash, ip_anonymized, ip_version, user_agent_hash).
GeoIP resolution, bot detection, IP anonymization, and referer classification are all delegated to
jeffersongoncalves/laravel-visitor-fingerprint —
see its README to configure the GeoIP driver (headers/ip_api/maxmind).
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email the author instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
