Search by

jeffersongoncalves / laravel-page-visits

jeffersongoncalves

Track page-view visits on any Laravel app's public routes, with device/browser/geo/locale/referer/UTM capture

1.0.3 2026-09-11 19:05 UTC

This package is auto-updated.

Last update: 2026-09-11 19:05:56 UTC


README

Laravel Page Visits

Laravel Page Visits

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads License

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.