Laravel SDK

Automatic server-side pageviews (middleware), a facade for events. Tracking happens 100% server-side, with no tracking cookies and no JS, invisible to ad blockers. Compatible with Laravel 10 to 13, PHP ≥ 8.1.

Installation

composer require quiet-metrics/laravel-metrics

The service provider and the facade alias are registered automatically (package discovery).

Configuration

Environment variables are enough in most cases:

QUIET_METRICS_PUBLIC_KEY=qm_pub_XXXXXXXXXXXXXXXXX
QUIET_METRICS_SECRET_KEY=qm_sec_XXXXXXXXXXXXXXXX
# QUIET_METRICS_ENDPOINT=https://quietmetrics.dev/api/v1/collect

A publishable configuration file is available if needed (config/quiet-metrics.php):

php artisan vendor:publish --tag=quiet-metrics-config

Automatic pageviews

The quiet-metrics middleware sends the page view in terminate(), after the response has been sent: no impact on perceived latency. Per route or per group:

Route::middleware('quiet-metrics')->group(function () {
    Route::get('/', HomeController::class);
    // …
});

To measure all your web traffic at once (Laravel 11+):

// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->appendToGroup('web', \QuietMetrics\Laravel\Middleware\TrackPageview::class);
})

Automatically ignored: non-GET requests, error responses, AJAX and requests expecting JSON; your APIs and your forms do not pollute your statistics.

Events

use QuietMetrics\Laravel\Facades\QuietMetrics;

QuietMetrics::event('signup', ['plan' => 'pro']);

From a job, a command or a listener (outside an HTTP request), there is no current URL: pass it explicitly, otherwise nothing is sent (silent drop):

QuietMetrics::event('import-finished', ['rows' => 1200], [
    'url' => 'https://mysite.com/imports',
]);

Edge cases

Octane, persistent workers. The context (URL, referrer, IP, User-Agent, language) comes from each request's Request object, never from superglobals. Nothing to configure.

Reverse proxy / CDN. The middleware reads $request->ip(): configure your Laravel application's trusted proxies as usual, and the visitor's real IP will follow. The core SDK's trust_proxy_headers option is only relevant outside Laravel.

Environments. Use a distinct site key per environment (staging vs production .env), or simply set no key in staging: without a public key, nothing is sent.

Tests. The client is a container singleton: swap it out to verify your events without any network calls.

use QuietMetrics\Client;

$fake = $this->mock(Client::class);
$fake->shouldReceive('event')->once()->with('signup', ['plan' => 'pro'], []);

$this->post('/register', [...])->assertRedirect();

Robustness contract

Sending is non-blocking (fire-and-forget socket, ~1 ms perceived, short cURL fallback) and every failure is silent: analytics never breaks the host site, even if the platform is unreachable.

Can't find your answer?

Support replies on business days.