Tracker
Laravel Stats Tracker
Install / Use
/learn @antonioribeiro/TrackerREADME
Laravel Stats Tracker
Tracker gathers a lot of information from your requests to identify and store:
- Sessions
- Page Views (hits on routes)
- Users (logged users)
- Devices (computer, smartphone, tablet...)
- Languages (preference, language range)
- User Devices (by, yeah, storing a cookie on each device)
- Browsers (Chrome, Mozilla Firefox, Safari, Internet Explorer...)
- Operating Systems (iOS, Mac OS, Linux, Windows...)
- Geo Location Data (Latitute, Longitude, Country and City)
- Routes and all its parameters
- Events
- Referers (url, medium, source, search term...)
- Exceptions/Errors
- Sql queries and all its bindings
- Url queries and all its arguments
- Database connections
Index
- Why?
- How To Use It
- Screenshots
- Blade Views
- Table Schemas
- System Requirements
- Installing
- Upgrading
- Changelog
- Contributing
Why?
Storing user tracking information, on indexed and normalized database tables, wastes less disk space and ease the extract of valuable information about your application and business.
Usage
As soon as you install and enable it, Tracker will start storing all information you tell it to, then you can in your application use the Tracker Facade to access everything. Here are some of the methods and relationships available:
Current Session/Visitor
$visitor = Tracker::currentSession();
Most of those methods return an Eloquent model or collection, so you can use not only its attributes, but also relational data:
var_dump( $visitor->client_ip );
var_dump( $visitor->device->is_mobile );
var_dump( $visitor->device->platform );
var_dump( $visitor->geoIp->city );
var_dump( $visitor->language->preference );
Sessions (visits)
$sessions = Tracker::sessions(60 * 24); // get sessions (visits) from the past day
foreach ($sessions as $session)
{
var_dump( $session->user->email );
var_dump( $session->device->kind . ' - ' . $session->device->platform );
var_dump( $session->agent->browser . ' - ' . $session->agent->browser_version );
var_dump( $session->geoIp->country_name );
foreach ($session->session->log as $log)
{
var_dump( $log->path );
}
}
Online Users
Brings all online sessions (logged and unlogged users)
$users = Tracker::onlineUsers(); // defaults to 3 minutes
Users
$users = Tracker::users(60 * 24);
User Devices
$users = Tracker::userDevices(60 * 24, $user->id);
Events
$events = Tracker::events(60 * 24);
Errors
$errors = Tracker::errors(60 * 24);
PageViews summary
$pageViews = Tracker::pageViews(60 * 24 * 30);
PageViews By Country summary
$pageViews = Tracker::pageViewsByCountry(60 * 24);
Filter range
You can send timestamp ranges to those methods using the Minutes class:
$range = new Minutes();
$range->setStart(Carbon::now()->subDays(2));
$range->setEnd(Carbon::now()->subDays(1));
Tracker::userDevices($range);
Routes By Name
Having a route of
Route::get('user/{id}', ['as' => 'user.profile', 'use' => 'UsersController@profile']);
You can use this method to select all hits on that particular route and count them using Laravel:
return Tracker::logByRouteName('user.profile')
->where(function($query)
{
$query
->where('parameter', 'id')
->where('value', 1);
})
->count();
And if you need count how many unique visitors accessed that route, you can do:
return Tracker::logByRouteName('tracker.stats.log')
->where(function($query)
{
$query
->where('parameter', 'uuid')
->where('value', '8b6faf82-00f1-4db9-88ad-32e58cfb4f9d');
})
->select('tracker_log.session_id')
->groupBy('tracker_log.session_id')
->distinct()
->count('tracker_log.session_id');
Screenshots
Visits
![]()
Charts
![]()
Users
![]()
Events
![]()
Errors
![]()
Blade Views
The views above are available in this package, but you need to install the sb-admin panel on your public folder, please look at the instructions below.
How data is stored
All tables are prefixed by tracker_, and here's an extract of some of them, showing columns and contents:
sessions
+-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
| id | uuid | user_id | device_id | agent_id | client_ip | referer_id | cookie_id | geoip_id | language_id |
+-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
| 1 | 09465be3-5930-4581-8711-5161f62c4373 | 1 | 1 | 1 | 186.228.127.245 | 2 | 1 | 2 | 3 |
| 2 | 07399969-0a19-47f0-862d-43b06d7cde45 | | 2 | 2 | 66.240.192.138 | | 2 | 2 | 2 |
+-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
devices
+----+----------+-------------+-------------+------------------+-----------+
| id | kind | model | platform | platform_version | is_mobile |
+----+----------+-------------+-------------+------------------+-----------+
| 1 | Computer | unavailable | Windows 8 | | |
| 2 | Tablet | iPad | iOS | 7.1.1 | 1 |
| 3 | Computer | unavailable | Windows XP | | |
| 5 | Computer | unavailable | Other | | |
| 6 | Computer | unavailable | Windows 7 | | |
| 7 | Computer | unavailable | Windows 8.1 | | |
| 8 | Phone | iPhone | iOS | 7.1 | 1 |
+----+----------+-------------+-------------+------------------+-----------+
agents
+----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
| id | name | browser | browser_version |
+----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
| 1 | Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 | Chrome | 35.0.1916 |
| 2 | Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/34.0.1847.18 Mobile/11D201 Safari/9537.53 | Chrome Mobile iOS | 34.0.1847 |
| 3 | Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) | IE | 6.0 |
| 4 | Python-urllib/2.6 | Other | |
| 5 | Other | Other | |
| 6 | Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36 | Chrome | 34.0.1847 |
| 7 | Mozilla/5.0 (Windows NT 6.3; rv:28.0) Gecko/20100101 Firefox/28.0 | Firefox | 28.0 |
| 8 | Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D169 Safari/9537.53 | Mobile Safari | 7.0 |
+----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
languages
+----+------------+----------------+
| id | preference | language_range |
+----+------------+----------------+
| 1 | en | ru=0.8,es=0.5 |
| 2 | es | en=0.7,ru=0.3 |
| 3 | ru | en=0.5,es=0.5 |
+----+------------+----------------+
domains
+----+--------------------------+
| id | name |
+----+--------------------------+
| 1 | antoniocarlosribeiro.com |
+----+-----------------
Related Skills
node-connect
354.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
