Skip to content

Install Statsdot on Laravel

Updated October 13, 2026

Add the script to the <head> of your main Blade layout, for example resources/views/layouts/app.blade.php, and wrap it in @production so local and staging environments do not send visits:

@production
    <script defer data-domain="yoursite.com" src="https://statsdot.com/js/script.js"></script>
@endproduction

Livewire and Inertia

wire:navigate in Livewire and page visits in Inertia change the URL with the browser's history API. Statsdot listens to it, so every page counts without extra code.

Events from your code

From a Blade view or a JavaScript component:

<button x-on:click="window.statsdot?.track('Download', 'Price list')">Download prices</button>

From a Livewire component, dispatch a browser event and track it:

$this->js("window.statsdot?.track('Signup')");

Content Security Policy

If your app sends a Content-Security-Policy header, allow the script and the endpoint it posts to:

script-src 'self' https://statsdot.com;
connect-src 'self' https://statsdot.com;