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.

Completely isolate ghost referrals without having to identify them

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.

Schematic representation of a fallback mechanism.

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.

Variable configuration for setting up a fallback mechanism to exclude ghost referrals.

So in total you need:

  • Variable "Page Hostname" - activate in the variable overview of the GTM
  • Loockup or regex table variable on "Page Hostname"
  • Variable with the property ID for live data
  • Variable with the property ID for the fallback for unwanted data

Separate GTM preview traffic (debug mode) and test traffic

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.

Variable configuration for setting up a fallback for GTM-Preview Traffic.

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.

Schematic representation of GA tracking with two fallbacks.

So in total you need:

  • Variable "Debug Mode" - activate in the GTM
  • "Page Hostname" variable - activate in the GTM
  • Loockup or regex table variable to "Debug Mode"
  • Loockup or regex table variable to "Page hostname"
  • Variable with the property ID for test data
  • Variable with the property ID for live data
  • Variable with the property ID for the fallback for unwanted data
Variable configuration to separate traffic from several host names into different properties.

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:

Schematic representation of tracking extended by additional fallback stations.

So in total you need:

  • Variable "Debug Mode" - activate in the GTM
  • "Page Hostname" variable - activate in the GTM
  • Loockup or regex table variable to "Debug Mode"
  • Loockup or regex table variable to "Page hostname"
  • Variable with the property ID for test data
  • Variable with the property ID for live data for domain 1
  • Variable with the property ID for live data for domain 2
  • Variable with the property ID for live data for domain 3
  • Variable with the property ID for the fallback for unwanted data

Conclusion

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.