Analytics filters with UA & GA4 (how & why)

There is a wealth of information about Google Analytics online. Yet people seem to find it so confusing when they get started and skip critical parts like filters and goals. 

You can find so much information in the Google knowledge base. Still people simply copy and paste the tracking and move on.

This article is written for anyone already using or thinking about using Google Analytics on their website. 

Reading this guide will help you setup Google Analytics and to understand how digital data analysis can help you work smarter.

Part 1 will show the beginner how to set up Google Analytics for digital tracking and analysis on your website. 

Part 2 will explain why you need filters and how to set up filters in Universal Analytics (UA) and Google Analytics 4 (GA4).

Depending on the feedback I get I may include a Part 3 about Goals and Conversion tracking later.

Can I skip Ahead to using filters with analytics?

If you are comfortable with concepts like properties, setting up multiple views and finding and implementing tracking codes you are welcome to skip ahead to part 2.

For everyone else we will go through the following steps to get you started on the right foot.

  • creating a Google Analytics account
  • enabling your account for both Universal Analytics (UA) and Google Analytics 4 (GA4)
  • Installing the tracking code on your domain

These 3 steps will have you up and running with a live and functioning digital reporting and data analysis environment.

Google Analytics 4 (GA4) is meant to replace Universal Analytics (UA). We will, however, install support for both UA and GA4. 

There are of course many more things you can do and implement with Google Analytics.

But this can also be part of the problem. The first step must be to get up and running. 

Then later you can worry about how to track conversions on sales funnels and email marketing campaigns.

Let’s build this kingdom one step at a time.

Part 1: Installing Google Analytics on your website

1. Creating an account.

Go to https://analytics.google.com and sign in to your Google Account. 

If you do not have a Google Account click “Create account”. Analytics is free to use but it does require a Google Account.

After creating or signing into your Google account you may need to click a button with the text “Start measuring” or something similar.

On the following 3 screens you name your account and property, specify your time zone and some other general settings. You also need to read and agree to terms and conditions to be able to continue with the setup.

Screen 1: Account setup

Specify your account name. This can be the name of your business or organization. Do not use a domain name if you intend to track more than one domain under your account.

Select the level of Data sharing you need and want and click “Next”.

Step 1 in analytics account set up
Step-1: Click image for larger version (opens in new window)

Screen 2: Property setup

Here you name your property. You can add more properties later. It is enough to list one property for now. Here it can make sense to list a domain name or website name.

Specify your preferred reporting time zone and the currency of your choosing. You can change these later if needed.

Step 2: Analytics property setup
Step 2: Defining your Analytics property (more properties can be added after setup)

Next click “Show advanced options”.

Here Google will inform you that Universal Analytics (UA) is soon to be replaced by Google Analytics 4 (GA4). Now, when I meet with companies UA is still widely used. 

I take the stance that until GA4 is widely announced as the replacement and also adopted by the vast majority of existing users, I recommend setting up support for both versions. 

To do so, check the slider to the right on the screen and proceed to write your website URL in the field below.

Check the radio button to set up both UA and GA4 and check to enable enhanced measurement for GA4.

When done click “Next”.

Step 2 Advanced options allows you to setup support for both UA and GA4
Step 2 Advanced options: Here you can setup support for both Universal Analytics and Google Analytics 4

Screen 3: About your business

Here you enter information about your business and then click “Create”.

On the next screen a popup will ask you to read and agree to the Google Analytics Terms of Service Agreement and possibly GDPR and other terms depending on your location.

If you check the box that you agree to the terms you will be taken to a page that shows your “Web streams details”. 

Check that your Stream URL and Stream name are spelled correctly and then click the “X” in the top left corner to close the view.

You will now be taken to your newly created Google Analytics Account with support for both Universal Analytics and Google Analytics 4. 

Welcome screen after Analytics account setup is completed
After account is completed you arrive at the Analytics Dashboard or Welcome screen

Installing the tracking code on your domain

You are now ready to use Google Analytics for digital analysis on your domain.

But for this to happen you need to install the Google Analytics tracking code on your website.

This code needs to be copied and pasted into the header section of every single page on your website.

If you use WordPress there are plugins you can use. If you are comfortable with making changes to code you can also paste the tracking code into the code yourself.

How to get the tracking code

  1. Go to the Admin tab
  2. Select the UA property in the second column named Property
  3. Click Tracking Info > Tracking Code

The tracking code will look something like this: 

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-1XXX-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-1XXX-1');
</script>

How to install the tracking code

For WordPress users there are several different Plugins to use. Or you can go to the WordPress dashboard and select Appearance > Theme Editor and then locate the header.php file in the right side column.

The tracking code should be inserter in the section labelled <head> for header. It may look something like this 

<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<link rel="profile" href="https://gmpg.org/xfn/11">
	<?php wp_head(); ?>

   >>> THIS IS WHERE YOU WOULD PASTE THE CODE <<<

	
</head>

Your header section may look different. This is no problem. What is important is that you should add the tracking code without changing any other code.

This means add as in do not remove or overwrite any existing code on the page. If you do your website may not work. If you feel unsure, ask someone for assistance or use a plugin if you have to.

Summary:

You have now created a Google Analytics account. The hierarchy is as follows:

There is one Account that you named on screen 1 in the setup. You can add more accounts later but often one account can be enough as it can have many Properties.

You have created two properties. One Universal Analytics property with a UA designator and one Google Analytics 4 property.  Your Universal Analytics property has also been given one view by default.

The Universal Analytics view is named “All Web Site Data” by default.

If you click Admin you can choose which property you want to work with.

You have also installed the Analytics tracking code on your website.

Right now you are Admin and you have no other users. Other users can be created but at this stage we stay as Admin as we have views to create for our Universal Analytics property in Part 2.

Part 2: How to set up filters in UA and GA4

Google has announced that GA4 is the way of the future. Still many people have reported difficulties getting used to GA4. 

Change in itself is often met with some level of “resistance”. And UA was and is a popular platform. 

Well, there are many differences between UA and GA4 and one of them is that GA4 does not use views.

And, you guessed it, views were a central part of how many users worked with UA.

Let’s back up and look at what filters are and what Views were used for.

Why use filters?

You use filters to clean your data. One example could be that  you do not want to count your own company’s traffic to your website as visits.

So how do we fix that?

We create a filter that excludes all traffic originating from your company’s IP address.

Filters start working from when they are created and applied. Filters do not process already recorded data. Filters will affect the data permanently and the filter effect cannot be reversed.

We can also use filters if we want to separate data using different parameters like point of origin.

You can have one filter to only show visitors from Europe and another to show visitors from Asia and North America respectively.

Applying filters in UA versus GA4?

Analytics filters are still available in both UA and GA4. But there is a major difference in how we build, view and work with them.

We will show how to set up filters for both UA and GA4. 

Still, I would like to point out one main difference.

Universal Analytics is built on a hierarchy where an account can have one or several properties and each property can have one or several views.

We apply filters on the view level. Ad filters on one view do not affect other views.

Each view is meant to create a unique report for us to look at and analyse.

Google Analytics 4 also has accounts that can have one or many properties. 

But GA4 does not use views.

Filters are applied directly on the property.

How filters are applied in Universal Analytics vs Google Analytics 4
How filters are applied differently in UA and GA4

Same result but new process and hierarchy

With Universal Analytics users got used to having one Raw Data View where all data was collected, unfiltered and not tampered with.

Filters would instead be applied to other views created for specific purposes.

Now with GA4 filters are applied directly on the property level. This means that traffic that is excluded with a filter is never processed, recorded or reported in Analytics.

Now, the data you filter (exclude) may be data you never would use anyway. Still, many people find it scary when there no longer is a Raw Data view as a backup.

If you still find the concept of views confusing please read on as it will get clearer as we move on to how to set up filters in UA and GA4 respectively.

We will configure one type of filter here to exclude traffic from your own internal IP.

You must work in the ADMIN tab when you are creating and editing filters. You should always create and test filters in the Test View before activating them on your live reporting data view(s).

Setting up filters in Universal Analytics (UA)

When you created your Google Analytics account you created a UA property.

It is recommended to have 3 views for each property in Universal Analytics:

  • Raw Data View that holds all data unfiltered
  • Master View where you view your reports
  • Test View where you test filters before applying them to Master
It is good practise to have 3 views for each property in Universal Analytics
Each property should have 3 separate views in Universal Analytics

If you need to create views you either click “Create View” or “View Settings” > “Copy view”. 

When we create filters we always work on the “Test view”. 

Select the “Test view” and then click “Filters”.

Next click “ADD FILTER” and 

  1. Select “Create new Filter”
  2. Name your filter “Exclude Internal IP”
  3. Use “Predefined”
  4. Select filter type “Exclude”
  5. Choose Select source or destination “traffic from the IP addresses”
  6. Select the expression “that are equal to” 
  7. List IP addresses you want to exclude 
  8. Click save and your filter is created

Testing the filter before going live on Master View

We only activated the filter for the Test View. To test the filter go to Analytics Real Time reporting by clicking Home > REPORTS > Realtime > Overview.

Next go to the website where you have installed the Analytics tracking code.

The number of visitors “Right now” does not include you as long as you are browsing from the IP address you listed in the filter.

Now go to Admin and click “All Filters” under Account.

Click on the filter you created “Exclude Internal IP” and remove from the “Selected views” box and click “Save”.

Go back to Realtime reports and verify that the filter is in fact working as intended. When you have confirmed that the filter is working as intended, go back to Admin > All Filters and add the filter to the Views where you want it to run following the same steps as before

I have my “Exclude Internal IP” filter on my Master View only. 

Setting up Analytics filters in Google Analytics 4 (GA4)

As we have already covered, filters are applied on the property level in GA4.

Click on the Admin tab and go to the Property column. Now select your GA4 property from the dropdown menu. The GA4 property is the property that does not start with “UA-”.

Filters are set on property level in GA4
Create filters in Google Analytics 4 on property level via Data Settings > Data Filters

Now click Data Settings > Data Filters and choose “Create Filter”.

On the next page select “Internal Traffic”.

Next you need to: 

  1. name your data filter: “Exclude Internal IP”
  2. specify filter operation: Exclude
  3. Label the traffic_type as: internal
  4. Set filter state to: testing

When completed click “Create

Next follow the same steps as above to verify that the filter is working as intended using Realtime reports before switching the Filter state to Active.

You can also look at reports and look for the identifier “Internal traffic” which indicates that the traffic would have been removed had the filter been active.

Keep in mind that when you change the filter state to active all incoming data matching the filter will be removed before processing. So do thorough tests before changing the filter state to Active.

Summary and conclusion

You now know why filters can be useful and how to set up filters in Universal Analytics (UA) and Google Analytics 4 (GA4).

You also know that as it stands at the moment GA4 is the future but UA is still very much in use.

There are some key takeaways that are important to remember:

  1. filters work with both UA and GA4 but the setup and process is quite different
  2. filters will affect data processed from the day the filters are created and activated
  3. data that is excluded by filters cannot be retrieved
  4. as excluded filter data cannot be retrieved you must test filters before making them active
  5. filters are permanent and will change the data in the report for as long as they are active

Meet the author: Mattias (Matt) is a serial entrepreneur and travel industry expert with more than 20 years of experience in business and web development. Mattias identifies with self-starters and entrepreneurs, loves to garden, and believes everyone needs a game plan for financial independence.