ssebetta / larnalytics
A simple web analytics tool for laravel projects
Installs: 35
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Type:package
pkg:composer/ssebetta/larnalytics
Requires
- guzzlehttp/guzzle: ^7.8
- jenssegers/agent: ^2.6
Requires (Dev)
- illuminate/database: ^8.0|^9.0|^10.0
- illuminate/http: ^8.0|^9.0|^10.0
- illuminate/routing: ^8.0|^9.0|^10.0
- illuminate/support: ^8.0|^9.0|^10.0
README
Larnalytics is a simple site analytics package for Laravel applications.
Installation
-
Require the package using Composer:
composer require ssebetta/larnalytics
-
Publish the package's configuration and migration files:
php artisan vendor:publish --provider="Ssebetta\Larnalytics\Providers\LarnalyticsServiceProvider" -
Run the migrations to create the necessary database tables:
php artisan migrate
-
Register the middleware in your
app/Http/Kernel.phpfile:protected $middlewareGroups = [ 'web' => [ // ... \Ssebetta\Larnalytics\Http\Middleware\TrackPageViews::class, ], ];
Extra
Run php artisan route:cache to access the analytics/page-views route
Usage
Larnalytics will automatically track page views and store the data in the page_views table.
Use
your-site-url/analytics/page-views to access the frontend view.
You can log custom events using the Analytics helper:
use Ssebetta\Larnalytics\Helpers\Analytics; Analytics::logEvent('event_name', ['key' => 'value']);