Updated: May 20, 2022
Originally Published: Oct. 21, 2020
Google Analytics 4 - GA4 - came out of beta on October 14, 2020 and has been on a tear ever since. Every week brings new updates and improvements. It's an incredibly fun time to be working with GA.
GA4 is easy to set up and it offers great insights with even a plain-vanilla installation. However, as with any tool, there are extra steps you should take to ensure you’re maximizing the GA4 setup for *your* website.
This guide is what I’ve discovered so far. I’ll keep adding to this post as I find more must-have setup tips.
And as the Google blog will remind you: you’re an early adopter! Expect the tool to keep changing quickly.
Index
A hostname filter has been an essential part of a good GA setup for years.
The hostname filter verifies that a user is on your website when their visit is recorded. It will block both spam traffic and traffic from your test, staging, or development environments.
If you’ve already set up a hostname filter in your Universal Analytics (UA) account, you may think you can apply it to your GA4 property. But no – none of the UA filters will work in GA4.
GA4 does collect the hostname – it’s part of every event (page_view, scroll, etc.).
Like many of the dimensions GA4 collects, it’s not easy to find the hostname in the GA4 UI, but if you search for “hostname”, you’ll find the “Top Hostname by Users” Insights card.
Nice!
In my case, clicking on that Insight showed me:
- the valid hostname (labeled 1 in the image – nwsdigital.com)
- invalid hostnames (labeled 2 – they’re all different test environments)
How to create a hostname filter in GA4
So far, there’s actually no way to create a valid hostname filter in GA4. But you can create one in Google Tag Manager (GTM).
In my case, I created a variable in GTM – a super-simple Lookup Table which checks the hostname (1). If it’s www.nwsdigital.com (2), then I output the GA4 Measurement ID (3).
This Lookup Table variable is then used in my GA4 configuration tag for the measurement ID:
Setting up a GA4 hostname filter with more than one hostname
It's not unusual to have more than one valid hostname. You may have separate domains for your marketing-automation tool, your payment processor, your cross-domain sites, etc.
You could still use a Lookup Table in GTM and add an additional row for each valid hostname. Or you could us a RegEx table.
I like RegEx tables, particularly if you have subdomains to work with. Here's what a GTM RegEx table would look like:
And then, of course, you would change the GA4 Tag to use the RegEx table.
Note: GA4 can be configured either via gtag (the Global snippet) or GTM. I configure everything through GTM (and recommend it in almost every case).
If you do use gtag, you won't be able to set up this type of hostname filter; it's only doable through GTM.
Other ways to see the hostname in the GA4 UI
At the beginning of this section, I talked about the Insights Card "Top Hostnames by User".
By default, that's the only way to see your hostnames in the UI, and you can't change the date range on that card.
If you wanted to see the hostnames that have been collected, you can see them in the Explore Hub.
Go into the Explorations, click on the "+" for dimensions (A), search for "hostname" (B) and click "Apply.
"Hostname" will then show in the list of dimensions.
You can drag the "hostname" dimension to a row, adjust the date range, and see the hostnames that have been collected. This is where you can look to verify which hostnames should be allowed, and which blocked.
Summary
In Universal Analytics, the hostname filter is set up in the “Filters” section in Admin and applied to a view. GA4 doesn’t have the same construct, but with a fairly simple tweak to GTM, you can build your own hostname filter. Well worth doing.
A word of caution, though: make sure to *test* your hostname filter, otherwise you might inadvertently block valid traffic. As we saw, a valid hostname filter will include your main domain and may also include separate domains for your marketing, blogs, cross-domain sites, etc.
(Shoutout to Mateusz Bratko for pointing out some updates to this section!)
(back to index)
If you’re creating a new GA property (which you do in the GA / Admin section), it may seem like you can only create a GA 4 property (1).
But no! Click on “Show advanced options” (2).
In the advanced options, you’ll see you can toggle the switch for “Create a Universal Analytics property” (1). I recommend doing this.
I would create both a GA 4 and UA property (2).
(As another tip, go ahead and set up the UA property using my 10 GA Admin pro tips.)
I think you're well served to have both GA4 and UA running at the same time. You can compare what you're getting between the two versions, to make sure your GA4 set up is done correctly. Also, many of the third-party tools which can read and integrate GA information rely on using "views" (old GA), not "streams" (new GA). Examples include Moz and Screaming Frog, but there are many more. The tool vendors will catch up - probably quickly - but in the meantime you don't want to lose that integration.
(back to index)
GA 4 will track several user interactions by default: page views, outbound links, downloaded files, scroll, video plays, and site-search terms. Those site-search terms are a great insight into your website visitors – they’re typing, into your website’s search box, exactly what they’re looking for. You definitely want to capture those.
Different websites use different conventions to indicate a search term. Some use the word “query” to show that; other common examples are “s” or “keyword”.
To see what your website uses, go to the search bar and type in something, then look at the URL. You’ll see something like this:
If the word or letter your website uses to designate a search term is “q,” “s,” “search,” “query,” or “keyword,” you’re in luck. Those are all covered by the default GA4 setting.
If you have something different, like we do on the Northwoods website, you have to make an adjustment. The phrase that designates a search term on our website is “Search_Keywords”.
If you don’t have one of the default search terms, let’s walk through how to make sure your search terms are being tracked.
To do these steps, you will need “Edit” rights in your GA4 account.
1. Go into the GA 4 Admin screen and click on the “Data Streams” option.
2. Click on the right arrow on your Web property.
3. In the “Enhanced measurement” window that opens up, click on “Show advanced settings” under Site search.
4. You can see the default search term parameters that already exist (in box 1). In box 2, type in the term or letter that your website uses to designate a search term. In Northwoods’ case, that’s “Search_Keywords." Then “SAVE” your work.
5. That's it! From this point forward, any search terms entered onto the site by your users will be captured.
(back to index)
While you’re in the GA 4 admin, go to “Data Retention” under the Data Settings Option.
By default, the data retention is set to "2 months."
You probably want to set that to the other option, 14 months.
There's much confusion over what this setting does. It has no impact on the standard aggregated reports in the UI - you'll be able to see information in those reports going back as long as you've collected data.
The setting does have an impact on the Explorations, though - if you are building your own set of reports, you won't be able to go back more than the 2 months or 14 months you specified. So it's a good idea to choose 14 months if you want any type of meaningful time-based Explorations.
Also: Note the toggle for “Reset user data on new activity." By default, that’s on, which makes sense. It just means that regardless of which limit you choose (2 months or 14 months), each time a user comes to your website, the clock resets on when their data will be deleted.
Make sure to "Save" your changes!
(back to index)
Here’s the best tip so far – not only because some day it’ll warn you about something catastrophic happening on your website, but because it’s kind-of hidden.
GA4 relies on machine-learning (ML) insights to supplement the stripped-down UI. Got something weird happening on your site? Ideally, an insight will report on that anomaly. But there are also some custom insights you'll want to enable.
The insights are available in a couple of places, including on the home page (1). Go ahead and click on “View all insights” (2).
In the next page (home / insights), click on "Create."
You’ll see a list of four “custom insights," all four of which could be important (depending on your website). But one of them will be important for all websites – the “Anomaly in daily views” (1). Here’s where you can set up a notification, which could be e-mailed to you, letting you know about anomalies in page views – e.g. you had zero page views today. I bet something’s broken!
Go ahead and click on the “Review and create” link (2).
Now you have a choice of specifying exactly what you want to be notified about. I can’t tell you how happy this makes me. It’s a wonderful practice to set up notifications when things are going wrong on your website. Most people don’t do this (it’s done through custom alerts in the older version of GA), but GA4 makes it very easy to set up. So easy, in fact, that I would accept the default of “Has anomaly." I think GA4’s ML will be able to figure this out just fine. I would for sure create the “daily views” custom insight; you can decide if it makes sense for your website to also enable the other custom insights.
Even better – you can create your own custom insights from scratch.
As small as these custom insights may seem, this is one of my favorite little features of GA4. I love proactively setting up alerts and it’s so frickin’ easy to do here. Nicely done, GA4 team!
Specify the e-mails of the people you want notified:
When you’re all done, go ahead and press the “Create” button.
When an anomaly happens, you'll get an e-mail like this one, which I got the day after I set up the hostname filters in tip 1:
At some point in the future, when that anomaly fires and you’re able to go in and resurrect your website tracking because something stupid broke – please send me an e-mail and thank me!
(back to index)
I know what you’re doing – you’re looking in the admin area to set up your filtered view, raw view, and test view. Right? Right?
(How do I know? Because only well-trained GA nerds would be reading this far into this blog post.)
Well, stop looking – there are no views and there’s no way to set up those views. At least as of right now. (A Google webinar I attended recently said they would be coming at some point - so don't lose hope.)
There are filters, though, which you can use for either internal traffic or dev/test environments. Let’s walk through setting up an “internal traffic” filter.
Start in the admin section of GA (1) and click on the “Data Streams” (2).
Click on the web stream for which you’ll create the filters:
Go to "Tagging Settings":
Click on "Define Internal Traffic":
Click on "Create":
You’ll now have your first opportunity to start adding an IP address (or multiple - up to 10 rows). Put in the name of the configuration (1), the match type (2), and the IP address (3).
There are multiple match types, but no RegEx option(!!). I can't tell you how painful that omission is.
Here’s a sample configuration filled out for my home IP address:
IMPORTANT: Even though GA4 uses “Anonymize IP” (dropping off the last octet in the IP address), for the “IP Address equals” option, you have to use the full IP address.
Save your changes. You’ll now see that configuration show up in your list of “internal traffic” rules.
Next, go back to “GA Admin / Data Settings / Data Filters”.
Make sure the Data Filter for Internal Traffic is set up. (I think this happens by default; I don’t think you have to do anything. But check to be sure.)
Now What?
Now you wait patiently. You won’t see any results of this filter until the next day.
The next day, you can use the dimension “Test data filter name” to look for traffic that is labeled “internal” or “not set” (i.e. external). Here is an example of the filter:
And here's where you can use it in a report in the UI:
You could also use it in the Analysis Hub, as a dimension for any of the reports you build. As a simple example:
- Specify a date range which includes the internal-traffic being set up.
- If the dimension is not there, click the + button and add the…
- “Test data filter name” dimension.
- Choose an Exploration report.
- Drag or choose the “Test data filter name” to the “Rows” section.
- You’ll now see the internal traffic and the not-set traffic.
Expect changes with the internal traffic filter
The IP filtering is so limited in GA4 compared to UA that I have to believe it'll be updated soon. The lack of RegEx in the match type is perhaps the biggest limitation right now - hard to see how to create an "internal traffic" channel for a large multi-site organization without having RegEx. Plus, of course, not having views available is painful. My personal opinion is that we'll see changes here in the near-term future.
Make the Internal Traffic Filter Live?
I think it’s great to set up the internal traffic filter – but leave it in test mode. You can always do your analysis and exclude that segment, either in the GA4 interface or in Big Query. But since there is only one “view” in GA 4, I’m reluctant to start excluding traffic that you’ll never get back. Mess up that IP filter and the data is gone forever – there’s no raw view on which to fall back.
But if you *really* want to make the internal-traffic filter live
Here's how.
- In the GA4 Admin screen, choose Data Settings / Data Filters
- Click on the three dots on the "Internal Traffic" line.
- Activate the Filter
You'll get a warning screen. Pay attention to it. Have you really tested the internal-traffic filter? Are you sure? if so, choose "Activate filter".
You'll now see that the internal-traffic filter is active.
Again, my strong recommendation is NOT to make it active. Without a raw view to fall back on, it's too risky to start excluding traffic, particularly since you can easily filter out the internal traffic in the GA4 UI, in BigQuery, or in Google Data Studio.
(back to index)
Here’s a simple idea – make sure that every report you create in Explorations has a name.
Otherwise, once you start creating reports, you’ll be hard pressed to remember what’s in the myriad “Untitled exploration” reports.
(back to index)
Honestly one of the most impressive features of GA4 is its built-in integration with BigQuery (part of the Google Cloud Platform). You can set up automatic export of GA4 data directly into BigQuery and specify whether you want to do that once per day, or virtually instantaneous. The “once per day” option is, essentially, going to be free (depending on how much data you have). For the “instantaneous” exports, you’ll have to set up a billing account.
I won’t try to recreate the excellent blog post that Charles Farina wrote on setting up BigQuery – go ahead and follow his steps and in about a day you’ll start getting data like this, which clearly shows the event / parameters structure of GA4:
Why should you care? Ultimately, I suspect much of the GA4 analysis is going to be done based on the data that’s stored in Big Query. Once the data is in BigQuery, you have a whole new world of processing and analysis open to you – much more than you’ll have within GA4 itself.
(back to index)
The hostname and IP filters are two of many reasons why I think GA4 should run alongside the older version of GA.
The GA4 UI (user interface) is totally different. It will take some time for all the analysts who worked with the older version – myself included - to truly “grok” the newer version. But by comparing the new to the old, you can understand and dig into the differences.
When you compare GA4 to Universal Analytics (UA), use the "raw" or unfiltered view in UA (assuming you’ve set that up). The raw view will be the closest to what you’ll see in GA4, because the filtering capabilities are still so limited in GA4.
Thankfully, it's very easy to dual-tag your site and run both Universal Analytics and GA4. You'll do yourself a favor by running both.
(back to index)
One of the enhanced measurements set up by default in GA4 is scroll tracking. It’s loaded on every page and fires when the visitor gets 90% of the way down the page.
This approach is smart.
Universal Analytics' scroll depth not as smart. It's usually set to track at the 10, 25, 50, and 75% marks – which means A LOT of noise gets sent to GA. When you set it up that way, scroll-depth tracking is usually the #1 event, by far, in GA.
That’s a lot of data and very little information.
GA4’s approach, by contrast, is a nice attempt to capture meaningful data and not inundate with noise.
Sometimes, though, you’ll want to track scroll depth at more than just the 90% mark – e.g. for blogs or other long-form content. Personally, I like to track those at the 25, 50, and 75% marks.
There’s good news! If you already have scroll-depth-tracking set up in GTM for your UA implementation, it’s easy to adjust to GA4.
Note: if you’re interested in this tip, I’m going to assume you already have scroll-depth set up in GTM. If you haven’t set it up yet, you have two options:
- Download a container file with scroll-depth tracking already set up. (This is just one of the many excellent resources from Julius Fedorivicius at analyticsmania.com.)
- Learn how to do it yourself (courtesy of the fine folks at seerinteractive.com)
Steps to add more Scroll Tracking in GA4, Using GTM.
Note: I’m going to assume you have some familiarity with Google Tag Manager (GTM), so I’m going to highlight the most important steps you’ll need to take along the way. The missing steps (like “Click on ‘New’ to create a new tag.”) will be familiar to most people who have worked in GTM a bit. Please feel free to reach out to me if you’d like further clarification, though.
1. In GTM, you’ll need the “Scroll Depth Threshold” and “Scroll Depth Units” enabled in the built-in variables section. (Your container may also have “Scroll Direction” enabled.)
2. You’ll need a scroll-depth trigger. Two important notes:
-
You can set the percentages to whatever you want. In this case, the percentages of 25, 50, 75, and 100% ill end up getting added to the 90% built-in GA4 scroll tracking.
-
I recommend only firing the trigger on certain sections of your site (the “/blog” pages in this example).
3. Create a new tag of type “GA4 Event”.
4. With this new tag (see screenshot for steps):
- Name it however you’d like.
- Use the name of the GA4 configuration tag you’ve previously set up in GTM.
- Make sure to use “scroll” as the event name. “scroll” is the GA4-recognized event name for the scroll-depth tracking; if you use any other name, set up is going to be harder.
- Add event parameter and use “percent_scrolled” for the Parameter Name. Again, you want to be consistent with what GA4 uses for scroll events.
- Use one of the variables you configured in step 1, above - “{{Scroll Depth Threshold}}”.
- Finally, use the trigger you set up in step 2, above.
5. Save the tag and then go into GTM Preview mode.
6. You can either look at the events in GTM’s Preview tab, or in GA4’s Debug View. I’ll show the latter.
7. Go to the DebugView in GA4 (“A” in screenshot below). On your website, go to one of the pages where you set up the extra scroll tracking (e.g. the /blog pages, in my example.) Scroll down the page. You’ll see the scroll events show up in the DebugView (“B” in screenshot).
8. Click on one of the “scroll” events so you can see the parameters. You should see “percent_scrolled”, if you set it up correctly in your GTM tag, along with the value (75% in the screenshot below).
9. That’s it! You’ve now added supplementary scroll tracking in GA4 to a specific set of your pages. Nice job!
10. Assuming it’s all working right, go ahead and publish your GTM container.
(back to index)
Looking for more GA4 tips? Check out our GA4 Resource Hub!