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

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

jakeydevs/analytics
===================

A self-hosted analytic system for Laravel

v0.2.2(5y ago)4391[1 issues](https://github.com/jakeydevs/analytics/issues)MITPHPPHP &gt;=7.2

Since Oct 14Pushed 5y ago1 watchersCompare

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

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

Analytics
=========

[](#analytics)

Analytics is a simple website analytic package for Laravel giving you just enough data to be practical without any of the data-sharing, third party crazyness you get with hosted web analytic tools.

This plugin is being actively developed on stream by .

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

[](#installation)

System built on Laravel 8. Not tested on anything under version 8.

`$ composer require jakeydevs/analytics`

Once installed, run migrations to allow the system to record pageviews! To edit the configuration for the package, you can publish the config file to make edits:

`php artisan vendor:publish --provider="Jakeydevs\Analytics\AnalyticServiceProvider" --tag="config"`

Record Pageviews
----------------

[](#record-pageviews)

### Recorded Pageviews

[](#recorded-pageviews)

To record pageviews, you'll need to add a specific middleware to your routes. This middleware, when ran, will save each pageview to the system. The middleware is named `pageview`.

**To save on all pageviews to your system** set the middleware to run when the web routes are ran. The best way to do this is by setting the middleware on the RouteServiceProvider

`app\Providers\RouteServiceProvider.php`

```
Route::middleware(['web', 'pageview'])
  ->namespace($this->namespace)
  ->group(base_path('routes/web.php'));
```

### Provided methods

[](#provided-methods)

#### Dates

[](#dates)

Dates should be passed to the analytics model in as a `Period`. Examples are:

```
Period::days(7) //-- Gets the last 7 days
Period::days(0) //-- Gets today
Period::create(now(), now()->subMinutes(10)) //-- Gets last 10 minutes
```

You can also get a set of dates to compare to your period - useful for providing context to results - by using the compare method. Examples are

```
$period = Period::days(7);
$compare = Period::compare($period); //-- Gets the 7 days before that

$period = Period::days(0);
$compare = Period::compare($period); //-- Gets yesterdays data
```

#### Analytic Methods

[](#analytic-methods)

You can use these methods to get pageviews, unique sessions, the bounce rate or the average duration of time for a session (in seconds):

```
Jakeydevs\Analytics\Analytics::getPageviews(Period $period): int
Jakeydevs\Analytics\Analytics::getUnique(Period $period): int
Jakeydevs\Analytics\Analytics::getBounceRate(Period $period): float
Jakeydevs\Analytics\Analytics::getDuration(Period $period): int
```

You can also get aggregated information for any of the parsed data gathered (browser, os, device, location, paths).

```
Jakeydevs\Analytics\Analytics::getDataAggregate(Period $period, string $column): array
```

The data returned is an array with the column and sessions ordered high to low.

### View Components

[](#view-components)

The system comes with several [view components](https://laravel.com/docs/8.x/blade#components) out the box for working with the data. They are based on [Tailwind](https://tailwindcss.com/) and the design can be found below.

[![1](https://camo.githubusercontent.com/9a3d52b30b909665e6c63839cccfaaae15780f3ccc7f8d5bc2eefdd44d09c436/68747470733a2f2f6a616b65792e616d73332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f736974652f35445274756542746d59394a716851767448766c7341744c767054356151476d47446b45525263582e706e67)](https://camo.githubusercontent.com/9a3d52b30b909665e6c63839cccfaaae15780f3ccc7f8d5bc2eefdd44d09c436/68747470733a2f2f6a616b65792e616d73332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f736974652f35445274756542746d59394a716851767448766c7341744c767054356151476d47446b45525263582e706e67)

You can use these with the tags:

```
@php
$p = Period::days(7);
@endphp

```

FAQ
---

[](#faq)

**Is this GDPR comliant?**I think so? I am not a lawyer - and if you are not either, you should totally talk to one if you are worried about GDPR.

**Does this work on SPAs**At the moment no as it only records a pageview on a page request.

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

[](#contributing)

Contributions are welcome - please send a pull request. When the project matures we'll add more detailed contribution guidelines!

This repo is available as part of [Hacktoberfest 2020](https://hacktoberfest.digitalocean.com/) and is perfect for first timers! If you need help, please join me on streams on Tuesdays and Fridays between 1pm and 4pm (GMT)!

Features
--------

[](#features)

Please feel free to add pull requests for any of the below crossed - or ask for new features in the issues.

✅ Record a pageview (Middleware) ✅ Get data from system ✅ Parsing configuration ❌ Record a pageview (manually - useful for SPA) ❌ View components for basic analytics ❌ Tests ❌ How to add own data parsers ❌ Example dashboard

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

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

Total

2

Last Release

2035d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1290fa4a3d8c1e7dfbaf4b063ae47b90432661e8a9edb2cd3a4071553cbecf24?d=identicon)[jakeydevs](/maintainers/jakeydevs)

---

Top Contributors

[![jakeydevs](https://avatars.githubusercontent.com/u/1093096?v=4)](https://github.com/jakeydevs "jakeydevs (19 commits)")

---

Tags

analyticshacktoberfestlaravelphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[yourls/yourls

Your Own URL Shortener

11.9k27.7k1](/packages/yourls-yourls)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[gpslab/geoip2

A Symfony Bundle for the Maxmind GeoIP2 API

541.5M3](/packages/gpslab-geoip2)

PHPackages © 2026

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