laravel-clarity maintained by jeffersongoncalves

Laravel Clarity
Add Microsoft Clarity — free heatmaps, session recordings and insights — to your Laravel app. The project ID is stored in the database with spatie/laravel-settings, so you can change it at runtime (e.g. from an admin panel) instead of in .env.
For a Filament settings page, use jeffersongoncalves/filament-clarity.
Installation
composer require jeffersongoncalves/laravel-clarity
Publish and run the settings migration:
php artisan vendor:publish --tag=clarity-settings-migrations
php artisan migrate
Configuration
Copy the project ID from Clarity (Settings > Setup) and save it:
use JeffersonGoncalves\Clarity\Settings\ClaritySettings;
$settings = app(ClaritySettings::class);
$settings->project_id = 'abcd1234ef';
$settings->save();
Or with the helper or the Facade:
$settings = clarity_settings();
$settings->project_id = 'abcd1234ef';
$settings->save();
use JeffersonGoncalves\Clarity\Facades\Clarity;
$projectId = Clarity::getFacadeRoot()->project_id;
Available settings
| Setting | Type | Default | Description |
|---|---|---|---|
project_id |
?string |
null |
Your Clarity project ID. The tag only renders when it is set and alphanumeric. |
Usage
Add the tag to your Blade layout, inside <head>:
@include('clarity::script')
Nothing is rendered while the project ID is empty or invalid, so you can ship the include everywhere and enable tracking later.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.