Laravel
Add Humblytics Analytics to a Laravel Site
1 · Sign up (or log in)
Visit humblytics.com → Start Free Trial. Finish signup—or log in to your existing workspace.
2 · Add your website in Humblytics
In the sidebar, click Add Website.
Domain – enter your site's domain (omit
https://andwww)Site Name – internal label (e.g.
Marketing-Laravel)
Copy the snippet from Install Tracking Code:
html
<!-- Start Humblytics Tracking Code -->
<script async src="https://app.humblytics.com/hmbl.min.js?id=YOUR_ID_HERE"></script>
<!-- End Humblytics Tracking Code -->Keep this tab open—we'll return and click Verify Website once the tag is live.
3 · Add the script to your Laravel project
Option 1: Blade layout (recommended for most apps)
Best for: Traditional Blade template apps
Open your main layout file, typically:
resources/views/layouts/app.blade.phpOr
resources/views/layouts/master.blade.php
Add your Humblytics script just before the closing
</head>tag:
blade
Ensure your pages extend this layout:
blade
Note: The @production directive ensures the script only loads in production, not during local development.
Option 2: Using environment variables (recommended)
Best for: Managing multiple environments (staging, production)
Add your Humblytics ID to
.env:
env
In your layout file (
resources/views/layouts/app.blade.php):
blade
Add to
.env.productionor your production environment
Note: Replace YOUR_ID_HERE with your actual project ID from Humblytics.
Option 3: Blade component (Laravel 8+)
Best for: Modern Laravel apps using Blade components
Create a new component:
bash
Edit
app/View/Components/Analytics.php:
php
Create
resources/views/components/analytics.blade.php:
blade
Add to
config/services.php:
php
Add to your layout's
<head>:
blade
Multiple layouts
If your app uses multiple layout files (e.g., app.blade.php, guest.blade.php, admin.blade.php), add the script to each layout file, or:
Create a partial:
resources/views/partials/analytics.blade.phpAdd the Humblytics script to this file
Include in each layout:
@include('partials.analytics')
4 · Deploy and verify
Clear Laravel caches:
bash
Deploy your changes to production
Return to Humblytics and click Verify Website
Open your live site in a private/incognito window and refresh once
Within ~30 seconds you should see a green Verified badge and live visitor count
If verification fails, check:
Script ID matches your project in Humblytics
You deployed to production (not testing localhost)
You cleared Laravel's view cache
The
@productionor environment check allows the script to loadView page source (right-click → View Page Source) and search for "humblytics"
No ad-blockers or browser extensions are interfering
Debug in Laravel:
bash
5 · Explore & optimize
Dashboard – see traffic, top pages, and referrers
Heatmaps – auto-generated scroll and click maps
Experiments – run A/B tests directly from Humblytics
Last updated
Was this helpful?