The Localhost

Modern web development guides hints and tips.

Create a Custom Domain for Fathom Analytics

Fathom Analytics recently added a really neat feature for custom domains with their service.

What does that mean then? Well it’s for bypassing ad-blocking extensions, not that Fathom wants to collect all your data, far from it.

The purpose of this post is to cover setting up my custom domain as I have a specific domain provider and I’m using Vercel’s and Netlify for hosting my projects I want to add the Fathom custom domains to.

Fathom has provided instructions for Godaddy, CloudFlare, Hover and NameCheap however, Like I mentioned, I have a custom DNS with my domain provider and I’m not be able to add a new CNAME record which is what I need to generate my Fathom custom (sub)domain.

Create a custom domain

Fathom’s documentation covers it pretty well, you go into your settings panel on Fathom and add in the domain of your site which I followed, pretty straight forward.

Fathom then give me two values, the first is the sub-domain that I’m going to create and the other is the Fathom DNS server.

fathom dns record for a site

Add the custom domain to my site

I set about working out how to add a CNAME to this blog but couldn’t find any good examples so I reached out to Fathom with a tweet:

After I sent that I found this gist which detailed the command for adding the sub-domain which made sense to me.

Add DNS record in Vercel’s

With the two values from Fathom dashboard, the CNAME is the sub-domain and the VALUE is the DNS server.

So in the now CLI I did the following:

1now dns add cdrjcy CNAME

Then I checked that the changes were added using the now dns command to list out my DNS settings:

1now dns ls

It depends on how quickly these are propagated to see if the record is created, for me it was a refresh on the Fathom dashboard and it said the domain was active with a couple of emails from Fathom to confirm they were created.

DNS Editor for Vercel domains

It was after I worked out how to add the CNAME with the CLI that I found the DNS Editor for Vercel domains which Jack mentioned in the reply to my tweet! 🤦‍♂

It’s a free integration on the Vercel Marketplace which is super straightforward to use once you add it to your Vercel account you can pick it from the Integrations section on your Vercel Dashboard.

Select custom domain in site settings

Now that the domain is set up I need to select that in the Sites dashboard, click on the Site ID for my site the pick the domain from the select list and verify it’s working on my site that is already configured with Fathom.

pick custom domain in site settings

Add DNS record in Netlify

I’m going to do the same with Netlify now, it’s a bit more straightforward with Netlify, I go to my sites page, select Domains, pick my domain scroll to the bottom of the list and select ‘Add new record’, add the details from the Fathom Domains page.

create new dns record netlify

It didn’t take long to validate the record in the Fathoms setting page then I picked the custom domain like I did in the previous step.

Add a Table of Contents with Smooth scroll using Gatsby and MDX...
Add Analytics Tracking Links to your Markdown... →