Laravel Package

Laravel Site Stats

A self-hosted, cookieless web analytics package for Laravel that stores only daily aggregates, for developers who want to count one site or many on their own server.

The problem it solves

A site owner wants to know which pages are read, where visitors come from and which links they click, without setting cookies, asking for consent in a cookie banner or keeping personal data. Laravel Site Stats does this inside your own Laravel app: the tracking script never reads or writes cookies or browser storage, every report is a daily counter, and the data stays on your server.

Main features

  • Single site or many: install it in a site's own Laravel app to count that site, with the data in its own database and the statistics in its own admin; or let one installation count many websites, on other servers and not necessarily Laravel apps, with one line of script each. Both setups work in the same installation.
  • Tracking script: one dependency-free script counts page views, including path changes in single-page apps, outbound clicks, downloads, time on page and scroll depth. Custom events can be sent from JavaScript or, without any JavaScript, by marking an element with data-stats-* attributes.
  • Counting on the server: middleware records AI crawlers and assistants, which do not run JavaScript, and can optionally count page views on the server, so visitors without JavaScript are included and 404 pages are not. Other Laravel sites can send these events to a central installation in client mode.
  • Reports: pages, entry and exit pages, page-to-page moves, sources and UTM campaigns, countries, devices, browsers and languages, events, and AI referrals and fetches, with comparisons over complete days and CSV export.
  • Dashboard, Filament and API: a built-in dashboard in English and Simplified Chinese with no front-end build or CDN, which can also be shown inside your own Blade admin; an optional Filament plugin with a statistics page, a Sites resource and dashboard widgets; a token-protected read-only JSON API; and optional public view and event counts for display on your own pages.

Who it is for

Laravel developers and site owners who want traffic statistics for their own site, or for several websites, on their own server, without cookies or third-party analytics services.

What you need

  • A Laravel app on a supported PHP version; the README lists the supported PHP and Laravel versions. Install the package from Packagist with Composer.
  • MySQL, PostgreSQL or SQLite.
  • Laravel's scheduler running, for the maintenance task that ends idle visits and deletes expired salts and old aggregates.
  • A viewStats gate in your app that decides who may see the statistics; until you define it, nobody can.
  • For visitor countries: Cloudflare or another CDN that sends a country header, or a local country database file in the MaxMind DB format.

Data and privacy

IP addresses and User-Agent strings are used for a moment to compute a hash with a random salt that changes every day, and are never stored. The salt is deleted within 48 hours after the day ends, so a visitor cannot be followed across days or across sites; returning visitors and cross-day funnels are deliberately not possible. Only daily counts are kept, forever by default or for a set number of days. All data is stored in the database of your own Laravel app: nothing is sent to Datafrog LLC or any other third party, and no IP address is sent to a geolocation service. The repository's PRIVACY.md lists exactly what is processed and stored, with a paragraph you can adapt for your privacy policy.

Laravel Package Web Analytics Cookieless Open Source