Installation guides
Install on Laravel
Add the tag to the Blade layout that renders your pages' <head>.
Copy your snippet
In MetricRaven, open your site's Settings → Install card and copy the script tag. It already contains your site ID.
Paste it into your layout's head
Replace
YOUR_SITE_IDwith the public site ID from your site's Settings → Install card. The site ID is public and safe in browser code; never put your secret key in a page.resources/views/layouts/app.blade.php{{-- resources/views/layouts/app.blade.php --}} <!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <title>{{ config('app.name') }}</title> <script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID" ></script> @vite(['resources/css/app.css', 'resources/js/app.js']) </head> <body> {{-- ...your existing body... --}} </body> </html>Which file that is depends on your setup:
- Inertia (React, Vue or Svelte): the root template, usually
resources/views/app.blade.php. - Livewire or Blade: the layout your pages use, such as
resources/views/layouts/app.blade.phpor acomponents/layoutsfile. Add it to guest layouts too if you track signed-out pages.
- Inertia (React, Vue or Svelte): the root template, usually
Deploy and open your site
php artisan serveand*.testhosts from Valet or Herd are local and not tracked by default; check the deployed site.
Verify it works
Open your live website in a normal browser window (not an automated or embedded one). In the browser's Network panel, look for script.js and then a request to /api/v1/collect whose response contains ok: true. Open your site's Traffic tab and choose Refresh; the selected dates must include your visit.
Nothing showing? See Troubleshooting.
Optional: read the site ID from config
Handy when staging and production report to different MetricRaven sites.
// config/services.php · optional
'metricraven' => [
'site_id' => env('METRICRAVEN_SITE_ID'),
],
{{-- In the layout --}}
data-site-id="{{ config('services.metricraven.site_id') }}"Notes
- Inertia links and Livewire's
wire:navigatechange pages with the history API, which the tracker records. - Click between a few pages and check the Network panel shows one
/api/v1/collectpageview per navigation. Two per click means the tag is loaded twice. - To serve the script from your own domain, see the Laravel proxy.
Optional script attributes are listed in Install & verify. To exclude your own visits, see Exclude your visits.