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:// and www)

  • 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

Best for: Traditional Blade template apps

  1. Open your main layout file, typically:

    • resources/views/layouts/app.blade.php

    • Or resources/views/layouts/master.blade.php

  2. Add your Humblytics script just before the closing </head> tag:

blade

  1. Ensure your pages extend this layout:

blade

Note: The @production directive ensures the script only loads in production, not during local development.

Best for: Managing multiple environments (staging, production)

  1. Add your Humblytics ID to .env:

env

  1. In your layout file (resources/views/layouts/app.blade.php):

blade

  1. Add to .env.production or 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

  1. Create a new component:

bash

  1. Edit app/View/Components/Analytics.php:

php

  1. Create resources/views/components/analytics.blade.php:

blade

  1. Add to config/services.php:

php

  1. 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:

  1. Create a partial: resources/views/partials/analytics.blade.php

  2. Add the Humblytics script to this file

  3. Include in each layout: @include('partials.analytics')

4 · Deploy and verify

  1. Clear Laravel caches:

bash

  1. Deploy your changes to production

  2. Return to Humblytics and click Verify Website

  3. Open your live site in a private/incognito window and refresh once

  4. 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 @production or environment check allows the script to load

  • View 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?