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

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

donaldblessing/analytics
========================

Analytics for the Laravel framework.

05PHP

Since Oct 31Pushed 1y agoCompare

[ Source](https://github.com/donald-blessing/laravel-analytics)[ Packagist](https://packagist.org/packages/donaldblessing/analytics)[ RSS](/packages/donaldblessing-analytics/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-analytics)

[![Latest Stable Version](https://camo.githubusercontent.com/9cab7825f61826244a3eb7995c3cf6e685424c93c371db02e08ab2b5962693bb/68747470733a2f2f706f7365722e707567782e6f72672f646f6e616c64626c657373696e672f616e616c79746963732f76)](//packagist.org/packages/donaldblessing/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 donaldblessing/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,
];
```

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

15

—

LowBetter than 3% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 61.7% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/21b82d918731904c43c9918b8437a3dc8410675dbe41897ba577f943a3afb699?d=identicon)[donald-blessing](/maintainers/donald-blessing)

---

Top Contributors

[![andreaselia](https://avatars.githubusercontent.com/u/5033092?v=4)](https://github.com/andreaselia "andreaselia (116 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)")[![donald-blessing](https://avatars.githubusercontent.com/u/26378644?v=4)](https://github.com/donald-blessing "donald-blessing (10 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)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![justrau](https://avatars.githubusercontent.com/u/10882793?v=4)](https://github.com/justrau "justrau (1 commits)")[![muhammadmp97](https://avatars.githubusercontent.com/u/17279395?v=4)](https://github.com/muhammadmp97 "muhammadmp97 (1 commits)")

### Embed Badge

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

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

###  Alternatives

[antoineaugusti/easyphpcharts

A PHP class for chartjs.org charts.

252.8k](/packages/antoineaugusti-easyphpcharts)

PHPackages © 2026

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