Hey there, Benjamin from Loves Data here. Welcome back! In this video, I'm going to show
you how to exclude internal traffic from Google Analytics 4 (GA4). If you don't filter out your
own traffic, then you (and anybody else in your organization) will be included in your reports.
And if you're visiting your website a lot, this can skew some of your most important metrics.
So let's cover the steps to stop this from happening. [ Loves Data Intro ]
There are different ways you can exclude your internal traffic from showing up in your reports.
If you've searched online, then you might come across suggestions that include using
query parameters, campaign tags, and even setting an extra cookie on your browser. But
the most reliable way to exclude internal traffic is by filtering your IP address (or addresses) in
Google Analytics. Let's start with the basics... How do you find your IP address? One option is to
search on Google for... 'What is my IP address?' this will give you your current public IP address.
And you can use this when configuring Google Analytics. There are a few considerations
though. If you're at home, then it's likely that you're using a dynamic IP address.
This means that your IP address can change. This also means it's really hard to define your IP
address in Google Analytics. So if you really need to exclude your own traffic, then you will
probably need to ask your service provider for a static IP address that doesn't change.
And if you're at work, then talk to whoever looks after your internet access. They should
be able to tell you the IP addresses, or ranges you will need to exclude from Google Analytics.
Once you've found your IP address, addresses, or IP range,
then it's time to head to Google Analytics... There are two steps we need to complete,
the first step is to define our internal traffic. To do this, we select 'Data Streams'...
Then you will need to choose your data stream. We can see that I only have one data stream in my
demo account, but if you do have multiple streams, you will need to repeat this for every stream.
Okay, let's select the stream... Now we need to scroll to the bottom and
choose 'More Tagging Settings'... And we select 'Define Internal Traffic'...
One issue you might encounter when you exclude your own traffic is that it becomes impossible
to troubleshoot your implementation using the DebugView in Google Analytics. I'm hoping that
Google addresses this in the future, but I wanted to show you two techniques you can
use today to get around this issue. I'm going to create two traffic rules and I will show you why
in a moment. So let's click 'Create'... For my first rule, I'm going to define my IP address,
so I'm going to name the rule 'Traffic from Benjamin'... I'm going to change
the 'traffic_type value' to 'benjamin'... And I'm going to enter my IP address...
What this traffic rule will do, is it will add an additional parameter of
'traffic_type' with a value of 'benjamin' to the events that come from my IP address. And
we will configure a filter in a moment to exclude this traffic. Okay, now let's click 'Create'...
And I'm going to create one more filter. Let's click
'Create' again'... I'm going to name this rule 'Traffic from Loves Data'...
This time I'm going to leave 'internal' as the value of the 'traffic_type' parameter.
And I'm going to enter the IP address for the Loves Data office...
So this rule is basically for all other internal traffic that will be visiting the website.
Again, I will show you why I have done this in a moment. Now let's click 'Create'...
Okay, now I want to highlight, that if you're the only person you want to exclude from your reports,
then you only need to create one of these rules. And I would probably go with the second
rule we just created. On the other hand, if you have lots of people who are considered internal,
then you will probably need to create additional rules. Now let's navigate back...
And we need to select 'Data Settings'... And then 'Data Filters'... Now let's click 'Create
Filter'... Select 'Internal Traffic'... And let's name the filter 'Exclude Traffic from Benjamin'...
We're going to leave 'Exclude' selected... And we're going to change 'internal' to 'benjamin'
as this is what I entered for my rule. Then at the bottom, we're going to select 'Active'... This
filter will exclude my traffic from the reports in Google Analytics. Let's create the filter...
Now we're going to create another filter...
Let's select 'Internal Traffic' again... And let's name the filter 'Exclude Traffic
from Loves Data'... We're going to leave 'Exclude' selected and we're going to leave
'internal' as the value. This filter will exclude the second rule we created previously.
Now let's create the filter...
Okay, now that we've created the traffic rules and the filters, we will now be excluding our
internal traffic from Google Analytics. But the problem I mentioned previously
about using the DebugView still applies. Let's head to Google Tag Assistant to take a look...
Okay, so I've loaded tag assistant, and I'm going to open my demo website...
The website loads and we can see tag assistant has been enabled. This would normally mean that
we could use the DebugView in Google Analytics to check all of the events as they're collected.
So let's head to Google Analytics... Let's navigate to the DebugView...
And we can see nothing is coming through to the DebugView. This is because we've filtered our own
traffic from Google Analytics. And I'm not really sure why, but this does include the DebugView.
So how can we use the DebugView and exclude our internal traffic from Google Analytics?
Let's look at the first option. To do this, let's head back to the admin area...
And let's select 'Data Settings'...
And then 'Data Filters'... Now because we took the time to create two rules and two filters,
what we can do is simply disable the filter for our traffic while we use the DebugView.
Before we do this though, I want you to create one more filter. Let's click 'Create'... And
let's choose 'Developer Traffic'... Let's name the filter 'Exclude Developer Traffic'...
And let's leave 'Exclude' selected... And let's select 'Active' at the bottom...
This filter will let us use the DebugView, but the traffic will be excluded from the reports.
Let's click 'Create'... Now I can deactivate my filter...
And I can head back to tag assistant... And reload my website...
Now let's head back to Google Analytics... And let's navigate to the DebugView...
We can now see the debug events I've collected using tag assistant...
Once I've finished testing things out, I can then navigate back to the admin area...
Select 'Data Settings'...
Then 'Data Filters'... And reactive my filter to exclude my own traffic...
So that's one technique you can use to exclude your own traffic and make use of the DebugView.
It's not ideal, but this works no matter how you've added Google Analytics to your website.
It works if you're using a built-in integration, a plugin, or the gtag.js code.
Now I want to show you one more option if you're using Google Tag Manager.
Let's head to Google Tag Manager to take a look... Since we've already configured the
rule and filter in Google Analytics, we're going to make an adjustment in Google Tag Manager.
This will mean that when we use the preview mode, we will be able to see
the events collected in the DebugView. To do this, let's navigate to 'Variables'...
And let's click 'Configure' for the built-in variables...
We need to enable the 'Debug Mode' variable...
This variable returns a value of 'true' when we're previewing our Google Tag Manager container,
and 'false' when the container isn't being previewed. Okay, now let's close this...
And create a new user-defined variable... Let's name the variable 'Traffic Type'...
And let's select select 'Variable Configuration'... And choose 'Lookup
Table' as the variable type... Now let's select the 'Debug Mode' variable as the input...
And let's click 'Add Row'... Let's enter 'true' as the input... And enter 'debug' as the value...
This variable will look at the value returned by the debug mode variable we just enabled.
And when the value is 'true' it will output the value of 'debug'. We're going to use this in
our GA4 tag in just a moment. Let's click 'Save'... And let's navigate to 'Tags'...
Let's find our existing GA4 configuration tag... And select it... Let's click 'Tag
Configuration' to edit our tag... And let's select 'Fields to Set'...
And we're going to click 'Add Row'... Now let's enter 'traffic', 'underscore', 'type',
all lower case as the field name... And for the value on the left, we can enter
two opening curley brackets (or braces)... And then find our 'traffic type' variable...
Or if you prefer, you can click the icon on the right to select the variable too...
Now let's save our tag... And let's click 'Preview'...
I'm going to load my demo website...
And now I'm going to head back to tag assistant...
I'm going to select the GA4 measurement ID at the top... And then the page view event...
We can now see the traffic type which is represented by 'tt' now has a value of 'debug'...
This has overwritten the rule we setup in Google Analytics, which also means it won't be filtered
out as internal traffic. The technique we've covered in Google Tag Manager means you don't need
to make any further adjustments. Your internal traffic will be excluded from the report, and you
can use the DebugView when you're previewing your container using Google Tag Manager.
So that's how you can exclude your own traffic from Google Analytics 4 using traffic rules and
filters, and two ways you can continue to use the DebugView. Are you excluding internal traffic?
I'd love to know, let me know in the comments below. And if you found this video helpful,
please like it, so I know to make more video like this one. I'll see you in the next video!