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

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

lancodev/laravel-analytics
==========================

Laravel Analytics

0.7(3y ago)218[2 PRs](https://github.com/lancodev/laravel-analytics/pulls)MITPHPPHP ^8.1

Since Dec 12Pushed 1y agoCompare

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

READMEChangelog (8)Dependencies (14)Versions (11)Used By (0)

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

[](#laravel-analytics)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a3f2bbbe50b89013dfa6904a57ca18beb3ef96b747eff8dbbec2ed7a9462d034/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616e636f6465762f6c61726176656c2d616e616c79746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lancodev/laravel-analytics)[![GitHub Tests Action Status](https://camo.githubusercontent.com/112b258ea7295bf48ac1982515173498215faa40190e9c1458e64b9cd999a41d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6c616e636f6465762f6c61726176656c2d616e616c79746963732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/lancodev/laravel-analytics/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/74be5583cabb60f727beafaf38a55401aa259ea64f4d859f16b3b37d086f2f94/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6c616e636f6465762f6c61726176656c2d616e616c79746963732f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/lancodev/laravel-analytics/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/fca69bf9dfb91f8001a1c2e281cd223fe1a53667ccae19d203cf1e27d0823b54/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c616e636f6465762f6c61726176656c2d616e616c79746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lancodev/laravel-analytics)

This package provides a simple way to capture site analytics within your existing Laravel application.

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

[](#installation)

Install the package via composer:

```
composer require lancodev/laravel-analytics
```

Publish the components and views:

```
php artisan vendor:publish --tag="laravel-analytics-components"
php artisan vendor:publish --tag="analytics-views"
```

Run the package's install command:

```
php artisan analytics:install
```

Usage
-----

[](#usage)

### Trackable Trait

[](#trackable-trait)

The package provides an optional `Trackable` trait that can be used to assign page view analytics to a model. The trait provides a `pageViews` relationship that can be used to retrieve the page views for the model.

This would typically be implemented by the `User` model. However, it could also be implemented by any other model that you wish to track page views for.

To use the trait, simply add the following to your model:

```
namespace App\Models;

use Lancodev\LaravelAnalytics\Traits\Trackable;

class User
{
    use Trackable;
}
```

### Tracking

[](#tracking)

To begin tracking analytics, add the `` component to your layout file(s). This will add the necessary JavaScript to your application.

```

        My Application

        ``` content ```

```

The `` component accepts the following props:

- trackable: the morphable entity to track
    - Example: ``
    - This will associate all page view analytics with the current user

### Analytics Dashboard

[](#analytics-dashboard)

The package also provides a simple dashboard component that can be used to display analytics for your application.

The dashboard can be added to any view by adding the following:

```

```

This will add the following to your page:

[![analyticsdashboardscreenshot.png](screenshots/analytics-dashboard-screenshot.png)](screenshots/analytics-dashboard-screenshot.png)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Kyle Anderson](https://github.com/lancodev)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

8

Last Release

1229d ago

### Community

Maintainers

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

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![kylekanderson](https://avatars.githubusercontent.com/u/24831484?v=4)](https://github.com/kylekanderson "kylekanderson (6 commits)")

---

Tags

analyticslaravellaravelanalyticslaravel-analyticslancodev

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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