Bart Veneman

Creator of Project Wallace, analytics for CSS. <noscript>-fanboy. Serverless clearfix engineer. I can lift node_modules twice my own weight.

Anonimized user pages with Fathom Analytics

My Fathom Analytics dashboard for Project Wallace was showing me all url's of the app, including the ones where a profile and project name were part of the url, like so: I don't want this, because:

The solution

To get around this problem, I need to convert every url that contains user-data to a generic URL.

original url analytics url
/~bartveneman /~:user
/~bartveneman/my-project /~:user/:project
/~bartveneman/my-project/imports /~:user/:project/imports

Luckily I have a routes.js file in the Project Wallace Express app, which lists routes like this:

const routes = {
userProfile: "/~:user",
userProject: "/~:user/:project",
userProjectImports: "/~:user/:project/imports",
// etc.

Every route with user data starts with /~, so I use that to determine whether Fathom should do it's regular reporting or whether I should inject my own. Fathom has an option to disable automatic tracking on a page and to manually call trackPageview(). This is what it looks like in Project Wallace:

//- NOTE: auto='false' to disable Fathom's auto-tracking. I'm implementing my own.
script(src='' site=SITE_ID auto='false' defer id='fathom')

if currentUrl.startsWith('/~')
.addEventListener('load', function () {
url: '#{req.route.path}' // req.route.path => /~:user/:project

.addEventListener('load', function () {

The result

Fathom dashboard with anonimized user urls

More privacy. More better.