GA4 - How do I only allow specific domains and filter out localhost
Asked Answered
L

2

6

How do I only allow google analytics 4 to get data from my approved domains rather than things like localhost etc? Does this feature exist?

Logrolling answered 27/12, 2020 at 17:39 Comment(2)
I’m voting to close this question because its not programming related may be better suited for webmasters.stackexchange.com or webapps.stackexchange.comGlabrous
we have this problem but it is spam bots (I assume) coming from hostname 127.0.0.1 and only seem to be able to be filtered easily from specific sections, eg Engagement > Pages and screensProvencal
W
3

So far [December 2020], there’s actually no way to create a valid hostname filter in GA4. You have to create a segment in the interface to analyze the data that interests you.

Westfalen answered 27/12, 2020 at 18:13 Comment(2)
That's a bummerLogrolling
It is a tool that is evolving, there will certainly be news in the coming monthsWestfalen
H
1

Filters in GA4 will probably not be added the way they were working for UA unfortunately.

There are a number of ways to go around this in order to "filter" out certain type of traffic such as localhost or other staging/test environments to be collected in your GA4 property.

You could create exception triggers in GTM that trigger whenever one of your tags fire from a test environment, this way the tags will "block" certain type of traffic from being collected in your GA4 property.

Another way to do this (my recommendation) is to create 2 separate GA4 properties, one for production and for staging (Master or Test). Then simply create a lookup table inside GTM and add it in your configuration tag as measurement id, where you add the domains and the measurement ID as output. So if the traffic originates from localhost send to G-1234 etc. This way the data would't be blocked in any way. A tip is to set a default value in the look up table so that all hostnames that aren't specified in the look up table sends data to the test property.

Hope it helps!

Hilten answered 19/12, 2022 at 18:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.