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.
$middleware->web(append: [
\Pirsch\Http\Middleware\TrackPageview::class,
]);
I have a fun solution to this problem for those in the future.
Create a new New Middlewere
$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
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;
}
}
1 Like
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.