# Laravel Integration | Handling Dynamic URL(s)

**URL:** https://forum.pirsch.io/t/laravel-integration-handling-dynamic-url-s/141
**Category:** Support
**Created:** [May 24, 2025, 11:30pm UTC](https://forum.pirsch.io/t/laravel-integration-handling-dynamic-url-s/141 "2025-05-24T23:30:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MattFalkner](https://forum.pirsch.io/user_avatar/forum.pirsch.io/mattfalkner/32/120_2.png) [@MattFalkner](https://forum.pirsch.io/u/MattFalkner)
#### Post date: [May 24, 2025, 11:30pm UTC](https://forum.pirsch.io/t/laravel-integration-handling-dynamic-url-s/141/1 "2025-05-24T23:30:31Z")

</div>

Hello,

Forgive my lack of understanding, I am new to tracking Analytics.

I am just getting started w/ the Laravel Integration and wondering how I handle URLs that embed data in them.

I see you have Filters to Exclude with Path based details like /endpoint/\* .  
Is there no way to group them together with such rules?

For example my dashboard looks like this  
/endpoint1/UUID1  
/endpoint1/UUID2  
/endpoint1/UUID3  
/endpoint1/UUID4  
/endpoint1/UUID5  
/endpoint1/UUID6  
/endpoint1/UUID7

I would like them to be grouped like /endpoint1/\* for example

Using the track page view with Dynamic URLs

What do people normally do when they encounter this. As I assume this must be a common issue.

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

```

---

<div class="post-metadata">

### Author: ![MattFalkner](https://forum.pirsch.io/user_avatar/forum.pirsch.io/mattfalkner/32/120_2.png) [@MattFalkner](https://forum.pirsch.io/u/MattFalkner)
#### Post date: [May 25, 2025, 2:41am UTC](https://forum.pirsch.io/t/laravel-integration-handling-dynamic-url-s/141/2 "2025-05-25T02:41:28Z")

</div>

I have a fun solution to this problem for those in the future.

Create a new New Middlewere

```auto
  $middleware->web(append: [
                \App\Http\Middleware\TrackPirschNormalized::class,
            ]);

```

Then Create a Middlewere that sends events out containing the name as

`$request->route()?->getName();`  
Which, in laravel is the name of the route defined in your web.php

//Example  
Route::get(‘/’, function () {  
})-\>name(‘home’);

Where now it will send ‘home’ as name

```php
<?php
namespace App\Http\Middleware;

use Closure;
use Pirsch\Facades\Pirsch;

class TrackPirschNormalized
{
    public function handle($request, Closure $next)
    {
        $response = $next($request);

        // fire after response is sent
        app()->terminating(function () use ($request) {
            // group by route name
            $routeName = $request->route()?->getName();

            if ($routeName) {
                Pirsch::track(name: $routeName);
                return;
            } else {
                // everything else use the real URL

                Pirsch::track();
            }
        });

        return $response;
    }
}

```

---

<div class="post-metadata">

### Author: ![Marvin](https://forum.pirsch.io/user_avatar/forum.pirsch.io/marvin/32/16_2.png) [@Marvin](https://forum.pirsch.io/u/Marvin)
#### Post date: [May 25, 2025, 5:16pm UTC](https://forum.pirsch.io/t/laravel-integration-handling-dynamic-url-s/141/3 "2025-05-25T17:16:27Z")

</div>

Hi Matt,

This is indeed what I would have recommended doing 🙂

An alternative would be to group pages using a conversion goal with a path pattern.
