Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Mar 26, 2024
1 parent 5892d64 commit abd0a71
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,52 @@ Pirsch::track(
],
);
```

### Filter pages

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

Create a new middleware like this:

```php
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<int,string>
*/
protected array $except = [
'url/to/exclude',
];

/**
* The Headers that should be excluded from tracking.
*
* @var array<int,string>
*/
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 on in your middleware configuration:

```php
protected $middlewareGroups = [
'web' => [
// ...
\App\Http\Middleware\TrackPageview::class,
],

// ...
];
```

0 comments on commit abd0a71

Please sign in to comment.