Laravel
Add Loamly to your Laravel site
Laravel is the most popular PHP framework, and adding Loamly tracking is as simple as pasting a script tag into your Blade layout file.
Add the tracking script
Open your main layout file (usually resources/views/layouts/app.blade.php) and add the Loamly script just before the closing </head> tag:
<!-- resources/views/layouts/app.blade.php -->
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@yield('title', config('app.name'))</title>
<!-- Loamly tracking script -->
<script src="https://app.loamly.ai/t.js?d=yourdomain.com" defer></script>
</head>
<body>
@yield('content')
</body>
</html>Replace yourdomain.com
yourdomain.com with the domain you registered in your Loamly workspace settings.Using @stack('scripts')
If your layout uses Blade stacks, you can push the Loamly script from any view or partial. This is a common Laravel pattern for managing scripts.
First, make sure your layout has a @stack directive in the head:
<!-- resources/views/layouts/app.blade.php -->
<head>
<meta charset="utf-8">
<title>@yield('title')</title>
@stack('scripts')
</head>Then push the Loamly script from your base view or a shared partial:
<!-- resources/views/partials/analytics.blade.php -->
@push('scripts')
<script src="https://app.loamly.ai/t.js?d=yourdomain.com" defer></script>
@endpushInclude the partial in your layout:
<!-- resources/views/layouts/app.blade.php -->
<body>
@yield('content')
@include('partials.analytics')
</body>Environment-based loading
@production
<script src="https://app.loamly.ai/t.js?d=yourdomain.com" defer></script>
@endproductionEnable AI verification (recommended)
The client-side script tracks page views, but to unlock the full power of Loamly you need server-side setup. This enables AI bot crawl detection, RFC 9421 signature verification, bot-to-click temporal matching, and prompt-to-crawl correlation with your Intelligence data. Without it, you miss the connection between AI bots crawling your site and the humans who visit after.
See the AI Visitor Verification guide for setup instructions.
Verify installation
- Visit your Laravel site in a browser
- Right-click → View Page Source
- Search for "loamly" to confirm the script is in the head
- Check your Loamly dashboard — the visit should appear within 2 minutes
Troubleshooting
Not seeing visits?
- Make sure the domain in the script tag matches the domain registered in your Loamly workspace settings
- Wait at least 2 minutes — data is not instant
- Check that the script is inside the
<head>tag, not the<body>
Ad blockers
- Some browser extensions may block tracking scripts. Try loading your site in an incognito/private window with extensions disabled
Debug mode
Open your browser's developer console and run:
Loamly.debug(true)This will log all tracking events to the console so you can verify everything is working.
Need help?