PHPackages                             monishroy/visitor-tracking - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. monishroy/visitor-tracking

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

monishroy/visitor-tracking
==========================

A Laravel package for tracking website visitors

v1.1.1(1y ago)1180↓86.7%3MITPHPPHP &gt;=7.4 &lt;8.5

Since Apr 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/monishroy/visitor-tracking)[ Packagist](https://packagist.org/packages/monishroy/visitor-tracking)[ Docs](https://github.com/monishroy/visitor-tracking)[ RSS](/packages/monishroy-visitor-tracking/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (11)Used By (0)

Visitor Tracking Package for Laravel
====================================

[](#visitor-tracking-package-for-laravel)

The `monishroy/visitor-tracking` package provides a simple way to track and analyze visitor data in your Laravel application, including total visitors, unique visitors, top visited pages, countries, operating systems, and devices.

Installation
------------

[](#installation)

1. **Install the Package**

    Require the package via Composer:

    ```
    composer require monishroy/visitor-tracking
    ```
2. **Run Database Migrations**

    After installing the package, run the migrations to set up the necessary database tables:

    ```
    php artisan migrate
    ```

Middleware
----------

[](#middleware)

The package includes a middleware aliased as `visitor_tracking` to track visitor data for specific routes. To use it, apply the middleware to your routes.

### Applying the Middleware

[](#applying-the-middleware)

You can apply the `visitor_tracking` middleware to individual routes or route groups in your `web.php` or `api.php` files.

#### Example: Single Route

[](#example-single-route)

```
Route::get('/home', [HomeController::class, 'index'])->middleware('visitor_tracking');
```

#### Example: Route Group

[](#example-route-group)

```
Route::middleware(['visitor_tracking'])->group(function () {
    Route::get('/home', [HomeController::class, 'index']);
    Route::get('/about', [AboutController::class, 'index']);
});
```

The middleware will automatically track visitor data for the routes it is applied to.

Usage
-----

[](#usage)

The package provides a `Visitor` facade to access visitor tracking data. You can use the following methods to retrieve analytics:

```
use Monishroy\VisitorTracking\Helpers\Visitor;

Visitor::totalVisitors(),     // Returns the total number of visitors
Visitor::uniqueVisitors(),    // Returns the count of unique visitors
Visitor::topVisitedPages($limit),   // Returns the most visited pages $limit = 5 default
Visitor::countries(),         // Returns visitor countries
Visitor::os(),                // Returns operating systems used by visitors
Visitor::devices()            // Returns devices used by visitors
```

### Example Output

[](#example-output)

Running the above code will dump the visitor data, which might look like this (example):

```
[
    "totalVisitors" => 1000,
    "uniqueVisitors" => 750,
    "topVisitedPages" => [
        [
            'page_title' => 'Home',
            'url' => 'https://example.com'
        ],[
            'page_title' => 'About',
            'url' => 'https://example.com/about'
        ],[
            'page_title' => 'Contact',
            'url' => 'https://example.com/contact'
        ],
    ],
    "countries" => [
        "US" => 400,
        "IN" => 300,
        "BD" => 100
    ],
    "os" => [
        "Windows" => 600,
        "MacOS" => 300,
        "Linux" => 100
    ],
    "devices" => [
        "Desktop" => 700,
        "Mobile" => 250,
        "Tablet" => 50
    ]
]
```

Customization
-------------

[](#customization)

### Using the VisitorTable Model

[](#using-the-visitortable-model)

The package includes a `VisitorTable` model that you can use to interact directly with the visitor tracking database table. This allows you to perform custom queries or extend the functionality.

#### Example: Querying Visitor Data

[](#example-querying-visitor-data)

```
use Monishroy\VisitorTracking\Models\VisitorTable;

$visitors = VisitorTable::where('country', 'US')->get();
foreach ($visitors as $visitor) {
    echo $visitor->page . ' visited from ' . $visitor->country;
}
```

You can also extend the `VisitorTable` model to add custom methods or relationships.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Laravel &gt;= 8.0

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

Support
-------

[](#support)

For issues or feature requests, please open an issue on the GitHub repository.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance46

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

10

Last Release

410d ago

PHP version history (4 changes)v1.0.0PHP &gt;=8.0

v1.0.3PHP ^8.2

v1.0.7PHP ^7.4|^8.1

v1.1.1PHP &gt;=7.4 &lt;8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/12014790f11f16599b5f9a676e85e0ac3917605f74ae78d131034e4167986e31?d=identicon)[monishroy](/maintainers/monishroy)

---

Top Contributors

[![monishroy](https://avatars.githubusercontent.com/u/125638057?v=4)](https://github.com/monishroy "monishroy (26 commits)")

---

Tags

laraveltrackingvisitor-countervisitor-trackinglaravel visitor trackinguser visitor tracking

### Embed Badge

![Health badge](/badges/monishroy-visitor-tracking/health.svg)

```
[![Health](https://phpackages.com/badges/monishroy-visitor-tracking/health.svg)](https://phpackages.com/packages/monishroy-visitor-tracking)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[nativephp/mobile

NativePHP for Mobile

1.1k75.1k91](/packages/nativephp-mobile)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[venturedrake/laravel-crm

A free open source CRM built as a package for laravel projects

43311.1k](/packages/venturedrake-laravel-crm)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
