How to add Google Analytics 4 to your Substack
A quick guide on how to get more interesting data
UPDATE: Only a few weeks after writing this post, Substack have now added proper integration. Woo! I’ll leave the post here for posterity, but go here for proper instructions.
This post is so boring that I didn’t send it out as a newsletter. But it lives here in case it’s of use to people.
First, let’s explain what this is all about:
Google Analytics is a free tool that helps website owners see what’s going on. This is on top of the built-in Substack stats.
In 2023 Google are switching everyone over to the latest version, Google Analytics 4, whether they like it or not.
At the time of writing, there’s no simple way to integrate GA4 with Substack. Hence this post. Hopefully it will become simpler at some point.
Why bother?
Good question. So:
Gather data about your Substack website, such as visitor numbers, which pages are most popular, where they’re coming from and so on.
You can segment and filter the data in far more sophisticated ways than you can using Substack’s built-in stats.
It’s free, so why not?
Probably lots of other reasons. Data, bla.
Why is it so complicated?
The older version of GA could be added to your Substack very easily, by simply adding the ID number into the appropriate box on your settings page, just here:
For the moment at least, there’s no way to do this with GA4. Instead you’re instructed to use Google Tag Manager.
At which point anyone who hasn’t done this before thinks what the heck is Google Tag Manager?
GTM is another free Google tool (honestly, they underpin so much of the modern web that it’s quietly alarming) that makes it easier (‘easier’) to add tags to a website. Rather than having to add code directly onto the pages every time you want to fiddle with tags, you add GTM once and then manage your tags within GTM itself.
Have you noticed every time I explain something I introduce another new term which I then have to explain? It’s most frustrating.
So, what is a tag? It can be all sorts of things - but for the sake of brevity, in our case it’s the bit of code that makes GA4 work on your Substack website.
DISCLAIMER: It’s unlikely you’ll break anything doing this, but it’s not impossible. This is all at your own risk, don’t do it if you’re worried about anything, etc etc.
Here’s the plan:
Step 1: Create your Google Analytics 4 property
First you need to create a Google Analytics account, and an accompanying GA4 property. I can’t really go into detail about this, and it’s all documented by Google, so the main thing is to follow their instructions carefully.
You can get started by going here and clicking the Get Started Today button.
Follow the instructions to create your account and then create a property.
Once you’ve created the property, you’ll need to go into admin, then property settings, and copy the property ID. You’ll need that in a moment.
Step 2: Create a Google Tag Manager container
Same general thing here. You need to create a GTM account and container.
Head over here, click Start for Free and follow the instructions.
Step 3: Add the Google Analytics 4 tag to your GTM container
You now need to add your GA4 details to your GTM container, by creating a tag.
Once you’re logged into your GTM account, inside your container you’ll see a weird interface that looks a bit like this:
See that Tags menu item on the left? Head in there.
Then click the New button up the top-right. This thing will slide out:
Right up the top, give your tag a name. GA4 - Substack
, for example.
Then click in the top box, Tag configuration. From the list that appears, select Google Analytics: GA4 Configuration.
In the Measurement ID that is now available, paste in your GA4 ID that you copied earlier:
Scroll down to the Triggering box. Surprisingly, this has nothing to do with manufactured culture wars and is actually quite useful. Click it, and choose the All pages trigger.
Click the Save button.
Your GA4 tag is now set up in GTM! That means you’re almost there. All that remains is to tell your Substack about it.
Step 4: Add your GTM to Substack
At the top of the GTM interface you can see your GTM ID. Copy that to the clipboard. It starts GTM-.
Now head over to your Substack, go into the Dashboard, then into Settings and scroll to the Analytics section.
In the Google Tag Manager ID slot, enter your GTM ID.
Note: Make sure you’re not putting your GA4 ID in here by mistake.
Step 5: Test & publish your GTM container
Your GTM container isn’t actually doing anything yet. First you need to test and publish.
So, back in GTM hit the Preview button. This appears:
Enter your Substack URL and click Connect. This loads up your site in a new window, and shows you which tags are firing. Click around a few pages and you should see your new GA4 tag firing each time:
If it all looks good, close the preview and then hit Submit. It’ll ask you for confirmation and details of changes, so bung something simple in there, then hit Publish.
And you’re done!
It’ll likely take a while to kick in, but you should now start to see data showing up in your GA4 property.
There are some other bits to consider which I won’t get into here, but you can investigate separately, like:
Excluding your own traffic
Linking Google Search Console
Setting up conversions
Customising your GA4 reports to be more useful
I don’t think you can edit the cookie/privacy policy on Substacks at the moment, either, which is a bit annoying. It seems strange to let people plug GTM into their Substacks but not make the cookie notice editable.
Hope that was useful. ✔