The Google Tag Manager (GTM) can fulfil very complex functions using scripts. However, it also offers some useful functions for beginners "out-of-the-box". These include, for example, the ability to route the measured traffic to various Google Analytics (GA) properties based on defined criteria. This control in GTM can be solved with the help of fallbacks, which can also be used for other purposes. This method is briefly presented below. The fallback logic itself is explained in detail.
Ghost referrals are nothing more than "fake" hits on your website. "Fake" because they didn't actually take place. This can have various causes: Either a GA tracking code including your GA tracking ID was used on another domain or a hit was sent directly to your ID.
Such ghost referrals can be separated in various ways. The most common method is using a filter directly in GA. However, this traffic must first be identified in GA, i.e. it must have already been received.
The alternative method using GTM is based on a fallback logic that is used to direct traffic to various GA properties. Instead of defining several exclusion criteria for ghost referrals in GA, inclusion criteria are defined for the desired traffic in GTM. The decisive inclusion criterion is your own domain. The corresponding traffic is sent to the designated property, the rest is dropped back into another property.
In GTM, this is realised with a lookup on the domain and uses a variable of the type Lookup-Table or RegEx-Table. This queries the "Page Hostname" called by the user - this is the "Input Variable" shown in the table.
So in total you need:
In GTM preview mode, you ideally want to see not only an isolated preview of unpublished GA tags, but also what the traffic in GA would look like if you were to publish the tags. On the one hand, this works with various browser tools such as the Console. However, you can also use the real-time view in GA. In order to distinguish your own actions from those of other visitors, it is best to use an additional fallback to a separate property that is only set up for this purpose.
To do this, set the variable "Debug Mode" as an input variable.
If the value of the variable is TRUE, the traffic flows into the designated debug property. In all other cases, you can refer to the previously defined inclusion criterion as a fallback: The query of your own domain to separate the ghost referrals.
So in total you need:
The time saving for setup and maintenance of a single GTM compared to several does not need to be discussed further. It also ensures homogeneous data collection on all country domains. If the "Lookup Hostname" table is extended by 3 additional domains, as in the example above, the logic would look like this:
So in total you need:
With the built-in functions and variables of the GTM, even beginners can achieve a lot. The principle illustrated here can be used for all possible criteria when it comes to distributing GA traffic to different properties.