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

AbandonedArchivedLibrary

starfolksoftware/analytics
==========================

Add analytics to your Laravel application

v0.9.1(5y ago)150[1 issues](https://github.com/starfolksoftware/analytics/issues)MITPHPPHP ^7.3.0

Since May 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/starfolksoftware/analytics)[ Packagist](https://packagist.org/packages/starfolksoftware/analytics)[ Docs](https://github.com/starfolksoftware/analytics)[ RSS](/packages/starfolksoftware-analytics/feed)WikiDiscussions develop Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

Add analytics to your Laravel application
=========================================

[](#add-analytics-to-your-laravel-application)

[![Latest Version on Packagist](https://camo.githubusercontent.com/25bb21820c7bd14445bffa100906116c14570305edb4d8cc99949ef7835c09ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746172666f6c6b736f6674776172652f616e616c79746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/starfolksoftware/analytics)[![Build Status](https://camo.githubusercontent.com/8df4ab6923ad9547fce87b2c72480eb8f209bdfd8cdb5153a5faf75f7d7c74a0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f73746172666f6c6b736f6674776172652f616e616c79746963732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/starfolksoftware/analytics)[![Total Downloads](https://camo.githubusercontent.com/43d6f66ff2af1fadfae47b90dce5a82dad486524ac333efcff07a7e58ac69c34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746172666f6c6b736f6674776172652f616e616c79746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/starfolksoftware/analytics)

Add the ability to associate analytics to your Laravel Eloquent models.

```
$post = Post::find(1);

event(new Viewed($post))
```

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

[](#installation)

You can install the package via composer:

```
composer require starfolksoftware/analytics
```

The package will automatically register itself.

You can publish the migration with:

```
php artisan vendor:publish --provider="StarfolkSoftware\Analytics\AnalyticsServiceProvider" --tag="migrations"
```

After the migration has been published you can create the media-table by running the migrations:

```
php artisan migrate
```

You can publish the config-file with:

```
php artisan vendor:publish --provider="StarfolkSoftware\Analytics\AnalyticsServiceProvider" --tag="config"
```

To register the `Viewed` event, `CaptureView` and `CaptureVisit` listeners, edit your `EventServiceProvider` as in the following:

```
  ...
  /**
   * The event listener mappings for the application.
   *
   * @var array
   */
  protected $listen = [
    'StarfolkSoftware\Analytics\Events\Viewed' => [
      'StarfolkSoftware\Analytics\Listeners\CaptureView',
      'StarfolkSoftware\Analytics\Listeners\CaptureVisit',
    ],
  ];
```

Usage
-----

[](#usage)

### Registering Models

[](#registering-models)

To let your models be able to have analytics, add the `HasViews`, `HasVisits` traits to the model classes.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use StarfolkSoftware\Analytics\Traits\{HasViews, HasVisits};

class Post extends Model
{
  use HasViews, HasVisits;
  ...
}
```

### Usage

[](#usage-1)

To trigger the viewed event on your model, you can call the `event()` helper method. It receives the intance of the `Viewed`.

```
$post = Post::find(1);

event(new Viewed($post))
```

This event triggers the `CaptureView` and `CaptureVisit` listeners.

### Retrieving Analytics

[](#retrieving-analytics)

The models that use the `HasViews` and `HasVisits` traits have access to it's analytics using the `views` and `visits` relations respectively:

```
$post = Post::find(1);

// Retrieve
$views = $post->views;
$visits = $post->visits;
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Faruk Nasir](https://github.com/frknasir)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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 ~178 days

Total

2

Last Release

2021d ago

PHP version history (2 changes)v0.9.0PHP ^7.2.5

v0.9.1PHP ^7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f609ab7be5e5a0089c8a3a52861fc379fd2038adb1190e0524c5f46a900fcf0?d=identicon)[starfolksoftware](/maintainers/starfolksoftware)

---

Top Contributors

[![frknasir](https://avatars.githubusercontent.com/u/4984175?v=4)](https://github.com/frknasir "frknasir (10 commits)")

---

Tags

analyticslaravel-packageanalyticsstarfolksoftwarestarfolk

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[irazasyed/laravel-gamp

Send analytics data to Google Analytics from Laravel. A package for GA Measurement Protocol API

3361.6M1](/packages/irazasyed-laravel-gamp)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[andreaselia/analytics

Analytics for the Laravel framework.

19719.5k2](/packages/andreaselia-analytics)[qodenl/laravel-posthog

Laravel implementation for Posthog

3372.7k](/packages/qodenl-laravel-posthog)[gtmassey/laravel-analytics

Create and run Google Analytics Data API queries in Laravel

3868.4k](/packages/gtmassey-laravel-analytics)

PHPackages © 2026

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