Installation
A few minutes from now, you will have a dashboard like this for your own app:

Composer
You can install the client package via composer:
composer require simplestats-io/laravel-clientINFO
At the moment, the following Laravel versions are supported: 11, 12 and 13.
For Laravel 8, 9 and 10 please use the client package up to and including version 3.
TIP
Not using Laravel? We also offer a basic plain PHP client that works with any PHP 8.2+ application.
Configuration
After you registered an account and got an API token, you should publish the config and set your SIMPLESTATS_API_TOKEN in your .env file.
INFO
The token will be displayed right after registration or when you create a new project. You can also find it later on the projects page in the app.
Publish the config file with the install command:
php artisan simplestats-client:installThis is the default contents of the configuration (you may tweak it to your needs):
TIP
We will go through the config step by step in the next section of this documentation guide.
use App\Models\User;
use Illuminate\Auth\Events\Login;
return [
/*
|--------------------------------------------------------------------------
| SimpleStats Settings
|--------------------------------------------------------------------------
|
| SimpleStats is enabled by default. Disabling it will stop tracking your stats.
|
| You can provide an array of URI's that must be ignored (eg. 'api/*')
*/
'enabled' => env('SIMPLESTATS_ENABLED', true),
'except' => [
'telescope*',
'horizon*',
'pulse*',
'admin*',
],
/*
|--------------------------------------------------------------------------
| SimpleStats Own Domains
|--------------------------------------------------------------------------
|
| Your app's own domain (from app.url) is never recorded as a referer. List
| further domains that belong to the same project here, e.g. a marketing
| site on Webflow or Next.js ('www.my-app.com'). They are not recorded as
| referers either, and beacon requests from their pages are counted, while
| beacon requests from any other site are ignored.
|
*/
'own_domains' => [
// 'my-app.com',
],
/*
|--------------------------------------------------------------------------
| SimpleStats Blocked IPs
|--------------------------------------------------------------------------
|
| Define IP addresses or CIDR ranges that should be excluded from tracking.
| Supports single IPs (e.g. '192.168.1.1') and CIDR notation (e.g. '10.0.0.0/8').
|
*/
'blocked_ips' => [
// '192.168.1.1',
// '10.0.0.0/8',
// '172.16.0.0/12',
],
/*
|--------------------------------------------------------------------------
| SimpleStats API Credentials
|--------------------------------------------------------------------------
|
| Define your API credentials here. If you are not told to change the API URL,
| just keep the default. It's important to set an API token! You'll receive
| one, after creating your team and project on https://simplestats.io
|
*/
'api_url' => env('SIMPLESTATS_API_URL', 'https://simplestats.io/api/v1/'),
'api_token' => env('SIMPLESTATS_API_TOKEN'),
/*
|--------------------------------------------------------------------------
| SimpleStats Queue
|--------------------------------------------------------------------------
|
| To avoid the tracking API calls block the whole request and for fault tolerance,
| we highly recommend using Laravel's built-in queue-system. Here you can define
| to which queue the tracking API calls should be dispatched and handled by.
|
*/
'queue' => env('SIMPLESTATS_QUEUE', 'default'),
/*
|--------------------------------------------------------------------------
| SimpleStats Log Errors
|--------------------------------------------------------------------------
|
| When enabled, the client will log API error responses (4xx, 5xx) to your
| application log on every failed attempt. Transient errors like connection
| timeouts are only logged on the final retry attempt.
|
*/
'log_errors' => env('SIMPLESTATS_LOG_ERRORS', false),
/*
|--------------------------------------------------------------------------
| SimpleStats Middleware Groups
|--------------------------------------------------------------------------
|
| Which middleware group(s) the CheckTracking middleware is appended to.
| Pick what matches your setup:
|
| - ['web'] : classic server-rendered apps (Blade, Inertia, Livewire)
| - ['api'] : headless / SPA frontends that only ever hit your API
| - ['web', 'api'] : hybrid setups (e.g. Blade marketing + SPA dashboard)
|
*/
'middleware_groups' => ['web'],
/*
|--------------------------------------------------------------------------
| SimpleStats Tracking Storage
|--------------------------------------------------------------------------
|
| Where to persist a visitor's attribution (UTMs, referer, entry page) so
| it survives across requests in the same day.
|
| - 'session' (default): stores the data in the user's session. Requires a
| session cookie and works only in classic, session-bound Laravel apps.
| Survives mobile IP changes because the cookie identifies the user.
|
| - 'cache': stores the data in Laravel's cache keyed by a daily hash of
| IP + User-Agent. Works in stateless / headless setups (JWT, SPA on a
| separate domain) where no session cookie is available. Loses precision
| when the visitor's IP changes (mobile network switches), which is the
| same trade-off privacy-first tools like Plausible and Fathom make to
| stay cookie- and consent-free.
|
*/
'tracking_storage' => 'session',
/*
|--------------------------------------------------------------------------
| SimpleStats Beacon
|--------------------------------------------------------------------------
|
| Only needed for pages that never reach your Laravel app: pages served
| from a static cache that bypasses PHP (Statamic "full measure" static
| caching, nginx/Varnish, Cloudflare "Cache Everything", ...), a
| marketing site outside Laravel (Next.js, Webflow, Framer, ...) or a
| single page app on another domain that talks to your API.
|
| Enabling this registers a tiny GET endpoint that returns a 1x1 pixel,
| plus a script at the same path with ".js" appended that requests it on
| every page view. Add it to your layout or to your marketing site:
|
| <script src="https://my-app.com/assets/v.js" defer></script>
|
| https://simplestats.io/docs/static-caching
|
| The route is registered in the first group listed in middleware_groups,
| so it always carries the tracking middleware.
|
| Pick a path that looks like a regular asset: paths containing "track",
| "stats", "analytics", "beacon", "collect" or "pixel" are blocked by
| common ad blocker lists, and a path with a file extension may be cached
| by your CDN before it ever reaches your app.
|
*/
'beacon' => [
'enabled' => env('SIMPLESTATS_BEACON_ENABLED', false),
'path' => env('SIMPLESTATS_BEACON_PATH', 'assets/v'),
],
/*
|--------------------------------------------------------------------------
| SimpleStats Page Views
|--------------------------------------------------------------------------
|
| Counts the pages each visitor opens, so you see how deep visitors from
| each channel browse and which pages are viewed most. Pages behind a
| login and the "except" list above are not counted.
|
| Page views are sent through your queue. They stay off while your queue
| connection is "sync", because every view would then slow down the page
| request. Run "php artisan simplestats:status" to check your setup.
|
*/
'page_views' => [
'enabled' => env('SIMPLESTATS_PAGE_VIEWS', true),
],
/*
|--------------------------------------------------------------------------
| SimpleStats Tracking Codes
|--------------------------------------------------------------------------
|
| Below you can set your tracking code URL param names. We already set some
| classical defaults for you, but you're free to change them as you like.
| Note that only the params which are listed here are getting tracked!
|
*/
'tracking_codes' => [
'source' => ['utm_source', 'ref'],
'medium' => ['utm_medium', 'adGroup', 'adGroupId'],
'campaign' => ['utm_campaign'],
'term' => ['utm_term'],
'content' => ['utm_content'],
],
/*
|--------------------------------------------------------------------------
| SimpleStats Tracking Types
|--------------------------------------------------------------------------
|
| Here you can set three different tracking types. The first is the login
| event. If this event gets dispatched, we track a login. The second is
| the user model. If such a model is created, we track a registration.
|
| As the payment model is named very individually, we did not set any default here.
| Give it the name of the model which holds your payments or transactions data.
|
| See: https://simplestats.io/docs
|
*/
'tracking_types' => [
'login' => [
'event' => Login::class,
],
// Make sure this model implements the TrackablePerson or
// the TrackablePersonWithCondition Contract
'user' => [
'model' => User::class,
],
// Using a supported payment package? Set its provider class and
// payments are tracked without any code, e.g.
// \SimpleStatsIo\LaravelClient\PaymentProviders\CashierMollie::class,
// \SimpleStatsIo\LaravelClient\PaymentProviders\CashierPaddle::class,
// \SimpleStatsIo\LaravelClient\PaymentProviders\CashierStripe::class,
// \SimpleStatsIo\LaravelClient\PaymentProviders\LemonSqueezy::class or
// \SimpleStatsIo\LaravelClient\PaymentProviders\Polar::class
// Otherwise set your own payment model, which must implement the
// TrackablePayment or TrackablePaymentWithCondition contract.
'payment' => [
'provider' => null,
'model' => null,
],
],
/*
|--------------------------------------------------------------------------
| SimpleStats Custom Properties Resolvers
|--------------------------------------------------------------------------
|
| Optionally set classes that resolve custom properties whenever a user
| or a visitor is tracked (e.g. an A/B test variant). The resolved
| properties are sent along with the track itself.
|
| The user resolver must implement the ResolvesUserCustomProperties
| contract, the visitor resolver the ResolvesVisitorCustomProperties
| contract.
|
*/
'custom_properties_resolvers' => [
'user' => null,
'visitor' => null,
],
];