PHPackages                             felipemateus/laravel-analytics - 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. felipemateus/laravel-analytics

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

felipemateus/laravel-analytics
==============================

Analytics for the Laravel framework.

1.0.2(2mo ago)0764MITPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5

Since Feb 4Pushed 2mo agoCompare

[ Source](https://github.com/eufelipemateus/laravel-analytics)[ Packagist](https://packagist.org/packages/felipemateus/laravel-analytics)[ GitHub Sponsors](https://github.com/andreaselia)[ RSS](/packages/felipemateus-laravel-analytics/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (22)Versions (7)Used By (0)

Laravel Analytics
=================

[](#laravel-analytics)

[![Latest Stable Version](https://camo.githubusercontent.com/1c110980105bfd974cf0e49029142002b4fc9196a7624d9df6b3e916c75bb9b3/68747470733a2f2f706f7365722e707567782e6f72672f66656c6970656d61746575732f6c61726176656c2d616e616c79746963732f76)](//packagist.org/packages/felipemateus/laravel-analytics)

Easily collect page view analytics with a beautifully simple to use dashboard.

[![Laravel Analytics Dashboard](/screenshot.png?raw=true "Laravel Analytics Dashboard")](/screenshot.png?raw=true)

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

[](#installation)

Install the package:

```
composer require felipemateus/laravel-analytics
```

Publish the config file and assets:

```
php artisan vendor:publish --provider="AndreasElia\Analytics\AnalyticsServiceProvider"
```

Don't forget to run the migrations:

```
php artisan migrate
```

You can add the page view middleware to a specific route group, e.g. `web.php` like so:

```
Route::middleware('analytics')->group(function () {
    // ...
});
```

Or add the page view to all middlewares/on an application level like so:

```
// app/Http/Kernel.php

protected $middleware = [
    // ...
    \AndreasElia\Analytics\Http\Middleware\Analytics::class,
];
```

Add app/Console/Kernel.php

```
    $schedule->command('app:update-pages-view-statitics')->everyTenMinutes();
```

Configuration
-------------

[](#configuration)

### Disabling tracking

[](#disabling-tracking)

You can disable tracking by setting the environment variable `ANALYTICS_ENABLED` or the `enabled` property in the `analytics.php` config file to `false`.

### Excluding routes

[](#excluding-routes)

You can exclude certain routes from being tracked by adding them to the `exclude` array in the `analytics.php` config file.

### Ignore robots

[](#ignore-robots)

You can ignore requests from robots by setting the `ignoreRobots` property in the `analytics.php` config file.

### Ignore specific IP addresses

[](#ignore-specific-ip-addresses)

You can ignore requests from specific IP addresses by adding them to the `ignoreIps` array in the `analytics.php` config file.

### Masking routes

[](#masking-routes)

You can mask certain routes from being tracked by adding them to the `mask` array in the `analytics.php` config file. This is useful if you want to track the same route with different parameters, e.g. `/users/1` and `/users/2` will be tracked as `/users/∗︎`.

### Ignoring certain HTTP verbs/methods

[](#ignoring-certain-http-verbsmethods)

You can ignore the tracking of some methods by adding them to the `analytics.ignoreMethods` config option. For example, if you don't want to track `POST` requests, you can configure it like so:

```
'ignoreMethods' => [
    'POST',
],
```

### Changing how session\_id is determined

[](#changing-how-session_id-is-determined)

By default, `session_id` in the `page_views` table is filled with the session ID of the current request. However, in certain scenarios (for example, for API and other requests not using cookies), the session is unavailable.

In these cases, you can create a custom session ID provider: create a class that implements the `AndreasElia\Analytics\Contracts\SessionProvider` interface and set its name as the `provider` option in the `analytics.php` config file. The configured class object is resolved from the container, therefore, dependency injection can be used via the `__constructor`.

One example of a custom way to generate the session ID in cookie-less environment is to hash IP address + User Agent + some other headers from the request.

Feel free to take a look at `AndreasElia\Analytics\RequestSessionProvider` for an example of implementing the `SessionProvider` interface.

### Changing how the timezone for "today" and "yesterday" is determined

[](#changing-how-the-timezone-for-today-and-yesterday-is-determined)

Since timestamps are stored using your application's timezone, you may get mixed results depending on when you check views for "today" and "yesterday" and your actual timezone. You can change the relative time for whatever "now" is by setting a callback in a service provider.

```
use AndreasElia\Analytics\Models\PageView;

public function boot()
{
    PageView::resolveTimezoneUsing(function () {
        return request()->user()?->timezone;
    });
}
```

You can return a dynamic value like the example above, or a static value. If one isn't determined, it will just fall back to the `config('app.timezone')` value.

Laravel Nova
------------

[](#laravel-nova)

The package comes with a dashboard and metrics for Laravel Nova.

### Dashboard

[](#dashboard)

You can add the dashboard to Laravel Nova by adding `new \AndreasElia\Analytics\Nova\Dashboards\Analytics` to `dashboards` array in your `NovaServiceProvider`:

```
    protected function dashboards(): array
    {
        return [
            new \AndreasElia\Analytics\Nova\Dashboards\Analytics,
        ];
    }
```

### Metrics

[](#metrics)

Alternatively, you can add the metrics to your own Laravel Nova dashboard by adding them to the `cards` array in your dashboard file.

```
    protected function cards(): array
    {
        return [
            new \AndreasElia\Analytics\Nova\Metrics\Devices,
            new \AndreasElia\Analytics\Nova\Metrics\PageViews,
            new \AndreasElia\Analytics\Nova\Metrics\UniqueUsers,
        ];
    }
```

Contributing
------------

[](#contributing)

You're more than welcome to submit a pull request, or if you're not feeling up to it - create an issue so someone else can pick it up.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance86

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 61.5% 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 ~183 days

Total

3

Last Release

73d ago

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

1.0.2PHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/d64d8328fcb931e610ec829e3266726ea27a5f16364fea3dd4d5e68c6ca10874?d=identicon)[eufelipemateus](/maintainers/eufelipemateus)

---

Top Contributors

[![andreaselia](https://avatars.githubusercontent.com/u/5033092?v=4)](https://github.com/andreaselia "andreaselia (118 commits)")[![tomirons](https://avatars.githubusercontent.com/u/5089787?v=4)](https://github.com/tomirons "tomirons (22 commits)")[![grantholle](https://avatars.githubusercontent.com/u/1189456?v=4)](https://github.com/grantholle "grantholle (22 commits)")[![eufelipemateus](https://avatars.githubusercontent.com/u/18071941?v=4)](https://github.com/eufelipemateus "eufelipemateus (11 commits)")[![Umfi](https://avatars.githubusercontent.com/u/13978552?v=4)](https://github.com/Umfi "Umfi (5 commits)")[![sinnbeck](https://avatars.githubusercontent.com/u/13980140?v=4)](https://github.com/sinnbeck "sinnbeck (5 commits)")[![myneid](https://avatars.githubusercontent.com/u/28316?v=4)](https://github.com/myneid "myneid (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (2 commits)")[![muhammadmp97](https://avatars.githubusercontent.com/u/17279395?v=4)](https://github.com/muhammadmp97 "muhammadmp97 (1 commits)")[![GlitterCakes](https://avatars.githubusercontent.com/u/5402396?v=4)](https://github.com/GlitterCakes "GlitterCakes (1 commits)")[![justrau](https://avatars.githubusercontent.com/u/10882793?v=4)](https://github.com/justrau "justrau (1 commits)")

---

Tags

middlewarelaravelpackageanalytics

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/felipemateus-laravel-analytics/health.svg)

```
[![Health](https://phpackages.com/badges/felipemateus-laravel-analytics/health.svg)](https://phpackages.com/packages/felipemateus-laravel-analytics)
```

###  Alternatives

[yajra/laravel-datatables-oracle

jQuery DataTables API for Laravel

4.9k33.8M339](/packages/yajra-laravel-datatables-oracle)[andreaselia/analytics

Analytics for the Laravel framework.

19719.5k2](/packages/andreaselia-analytics)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)

PHPackages © 2026

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