Tracking urls with unique user slugs with plausible

Posted 31 Jul 2021

If you run a SaaS plattform and use unique identifiers on a per model basis in your routes you know the nightmare that tracking these routes as one route brings to the table.

Imagine the following example: You run a SaaS that offers the user the ability to create servers and edit them. You use a route with the servers unique-id inside for editing: /servers/servier-uuid/edit. In Plausible, editing different servers shows up as different routes since the slug is part of the url and not part of the query string. 

Options provided by Plausible:

Pageview Goals

To get the total count of visits to the server edit route, plausible allows you to define a pageview goal. These use a regex pattern to group pageviews together. And sure enough, we can create a pageview goal with the pattern /servers/*/edit to see how many users visited the edit route. However, the unique uuids are still present inside the top pages tab. Depending on the context of your data this could be a data protection issue.


  • Shows all visits and every data needed
  • No code changes needed
  • Easy and Fast


  • Unique routes still inside Top Pages box (looks ugly and data protection problem)
  • A lot routes cluster custom events tab

Excluding routes

Another option you find in the plausible docs is to disable tracking on these specific routes. This is done by providing a data-exclude attribute with the plausible script tag. Just like the pageview goals, you just provide one or multiple regex pattern and every route that matches a pattern is excluded from beeing tracked. With this approach, we are not storing sensitive data inside plausible but we lose the ability to track pageviews alltogether.


  • Not private data stored
  • Not shown inside Top Pages box


  • Nothing stored
  • No ablility to get any analytics on these pages

The do it yourself way

After reverse engeneering the plausible tracking script I've came up with the idea to exclude these routes from plausibles automatic tracking (using the data-exlude attribute) and instead sending my own page view event with the slightly modified route without the uuids and instead a placeholder. As a result, every pageview of our /servers/server-uuid/edit would be sent to Plausible as /servers/-/edit, therefore shown as one route inside our Top Pages box and no personal ID is ever sent to plausible. 

To achive this, we just need to write some javascript so send our own pageview event. Luckily for you I've created a gist ( that contains the custom javascript. All it does is to check if the current route is inside the data-exclude array. If it is, it replaces the * with a - and sends the route as a custom pageview event to plausible.
All you need to to is to copy the code into your application javascript and add every route that contains uuids into the data-exclude array (and make sure you load the exclusions javascript from plausible).