PHPackages                             pirsch-analytics/laravel-pirsch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pirsch-analytics/laravel-pirsch

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pirsch-analytics/laravel-pirsch
===============================

Official Laravel integration for Pirsch Analytics.

1.1.0(3mo ago)4855.8k↑31.1%7[1 issues](https://github.com/pirsch-analytics/laravel-pirsch/issues)2MITPHPPHP ^8.2CI passing

Since Jun 12Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/pirsch-analytics/laravel-pirsch)[ Packagist](https://packagist.org/packages/pirsch-analytics/laravel-pirsch)[ Docs](https://github.com/pirsch-analytics/laravel-pirsch)[ GitHub Sponsors](https://github.com/zepfietje)[ RSS](/packages/pirsch-analytics-laravel-pirsch/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (28)Versions (23)Used By (2)

[![Packagist Version](https://camo.githubusercontent.com/958d3a9fda6c09642d920409d41d7e34539fa6a1015296292942daa3a35d0a98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7069727363682d616e616c79746963732f6c61726176656c2d706972736368)](https://packagist.org/packages/pirsch-analytics/laravel-pirsch)[![Packagist Downloads](https://camo.githubusercontent.com/cebdcad2ef0ad883c3c2e61446a4846bc28044496754cfb90dae6be21a0877af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7069727363682d616e616c79746963732f6c61726176656c2d706972736368)](https://packagist.org/packages/pirsch-analytics/laravel-pirsch/stats)

Pirsch for Laravel
==================

[](#pirsch-for-laravel)

This package is the official Laravel integration for [Pirsch Analytics](https://pirsch.io).

Installation
------------

[](#installation)

1. Install this package:

    ```
    composer require pirsch-analytics/laravel-pirsch
    ```
2. Add the Pirsch access token to your `.env` file. Leave it empty in non-production environments to disable tracking:

    1. Visit the [Pirsch "Integration" settings page](https://dashboard.pirsch.io/settings/integration).
    2. Make sure the correct domain is selected in the top left corner of the page.
    3. Scroll down to the "Clients" section and press the "Add Client" button.
    4. Select "Access Key (write-only)" as type and enter a description.
    5. Press the "Create Client" button and copy the generated "Client secret".
    6. Add the copied token to your `.env` file:

        ```
        # ...

        PIRSCH_TOKEN=pa_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        ```

Usage
-----

[](#usage)

### Track pageviews

[](#track-pageviews)

#### Automatically

[](#automatically)

This package comes with a `TrackPageview` middleware that allows you to track pageviews automatically. Apply the middleware to your web routes by appending it in the `withMiddleware` method in your `bootstrap/app.php` file:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Pirsch\Http\Middleware\TrackPageview::class,
    ]);
})
```

You can also apply the middleware to specific routes or groups:

```
use Pirsch\Http\Middleware\TrackPageview;

Route::middleware(TrackPageview::class)->group(function () {
    Route::get('/', function () {
        return view('welcome');
    });
});
```

#### Manually

[](#manually)

If you want to manually track pageviews instead, you can use the `Pirsch::track()` method. Calling this method without any arguments will track a pageview for the current HTTP request:

```
use Pirsch\Facades\Pirsch;

Pirsch::track();
```

### Track events

[](#track-events)

Pirsch allows you to [track custom events](https://docs.pirsch.io/dashboard/events) in order to measure additional information. You can use the `Pirsch::track()` method with a name and optional metadata to track an event:

```
use Pirsch\Facades\Pirsch;

Pirsch::track(
    name: 'Button clicked',
    meta: [
        'Label' => 'Get started',
    ],
);
```

### Filter pages

[](#filter-pages)

You can configure the `TrackPageview` middleware to exclude specific pages from being tracked.

On a specific rouute, you can exclude pages by adding a `except` property to the middleware class:

```
use Pirsch\Http\Middleware\TrackPageview;

Route::middleware(TrackPageview::class.':url/to/exclude/*')->group(function () {
    Route::get('/', function () {
        return view('welcome');
    });
});
```

Multiple urls can be excluded by separating them with a comma:

```
use Pirsch\Http\Middleware\TrackPageview;

Route::middleware(TrackPageview::class.':url/to/exclude/*,url/to/exclude2/*')->group(function () {
    Route::get('/', function () {
        return view('welcome');
    });
});
```

To exclude pages globally, you can create a new middleware that extends the `TrackPageview` middleware and add an `except` property:

```
namespace App\Http\Middleware;

use Pirsch\Http\Middleware\TrackPageview as Middleware;

class TrackPageview extends Middleware
{
    /**
     * The URIs that should be excluded from tracking.
     *
     * @var array
     */
    protected array $except = [
        'url/to/exclude/*',
    ];

    /**
     * The Headers that should be excluded from tracking.
     *
     * @var array
     */
    protected array $exceptHeaders = [
        'X-ExcludedHeader',
    ];
}
```

- `except` is an array with all URIs paths taht you want to exclude from tracking.
- `exceptHeaders` is an array with all Headers that you want to exclude from tracking.

Then replace the `TrackPageview` middleware with this one on your `bootstrap/app.php` middleware configuration:

```
  ->withMiddleware(function (Middleware $middleware) {
      $middleware->web(append: [
-         \Pirsch\Http\Middleware\TrackPageview::class,
+         \App\Http\Middleware\TrackPageview::class,
      ]);
  })
```

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance81

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 75.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~66 days

Recently: every ~230 days

Total

22

Last Release

95d ago

Major Versions

0.4.10 → 1.0.02025-03-20

PHP version history (2 changes)0.1.0PHP ^8.1

1.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce6070fcd234c4bb3e39b6583ccc2d960ba9a11e1f23d3aa49caeda90bc98b0a?d=identicon)[m5blum](/maintainers/m5blum)

---

Top Contributors

[![zepfietje](https://avatars.githubusercontent.com/u/44533235?v=4)](https://github.com/zepfietje "zepfietje (49 commits)")[![asbiin](https://avatars.githubusercontent.com/u/25419741?v=4)](https://github.com/asbiin "asbiin (6 commits)")[![Kugelschieber](https://avatars.githubusercontent.com/u/6115423?v=4)](https://github.com/Kugelschieber "Kugelschieber (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![xyNNN](https://avatars.githubusercontent.com/u/1929750?v=4)](https://github.com/xyNNN "xyNNN (3 commits)")[![Autive](https://avatars.githubusercontent.com/u/6318898?v=4)](https://github.com/Autive "Autive (1 commits)")

---

Tags

analyticslaravelphplaravelpirsch-analyticslaravel-pirsch

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pirsch-analytics-laravel-pirsch/health.svg)

```
[![Health](https://phpackages.com/badges/pirsch-analytics-laravel-pirsch/health.svg)](https://phpackages.com/packages/pirsch-analytics-laravel-pirsch)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
