September 22, 2021
Triggers in Server Google Tag Manager Containers
When server-side Google Tag Manager was introduced, there was only one type of trigger, Custom. But when the number of them increased, it’s time for a quick blog post explaining each type and their differences. Let’s take a look at triggers in Server Google Tag Manager containers.
By the way, if you want to learn much more about server-side GTM setup, take a look at my Intermediate/Advanced GTM course.
This blog post assumes that you already have at least a very basic understanding of how SGTM works. If you are completely new to this, take a look at this tutorial first. P.S. you would learn much more about SGTM in this course.
As of the moment of writing this article, there are 3 types of triggers, Custom, Page View, and Custom event.
In the future, the number of them might grow.
Custom trigger in server Google Tag Manager
This type of triggers is the first one that was available when SGTM was launched. When a Server Container Client accepts the incoming request, processes it, and makes its data available in the container for other tags, you can use a Custom trigger to fire a tag.
An example of a Custom trigger could look like this:
It means that the tag will fire on any incoming request that was processed by a Client named GA4.
If you want, you can use different conditions in a trigger. For example, if you want your trigger to be activated ONLY when the incoming request contains a specific GA4 measurement ID (e.g. G-1234567), then your trigger’s condition could look like this (Note: you first must enable the built-in Query String variable in the Variables > Configure section):
And that is pretty much what you need to know about the custom trigger. You specify conditions in the trigger and when every time a request is processed by any client in the server container, the trigger will be evaluated. If trigger conditions are met, it is activated and all linked tags will fire.
Page View trigger in server Google Tag Manager
This trigger (as well as the Custom Event trigger) is created to make the lives of SGTM users a little more convenient. There is nothing groundbreaking here, just a little bit more convenience.
Page View trigger (including All Pages) trigger means that: “the trigger will be activated if the incoming request was processed by a client and generated a page_view event. That event should be visible in the preview mode of server GTM:
You could re-create the same trigger condition by using the aforementioned Custom trigger where the condition is “Event Name” is “page_view”.
The most common example of when can you get this kind of event in the server GTM container is when you have GA4 tags (in the web container), those tags send data to your server-side endpoint AND you have a GA4 client configured in the server container. So when the web GA4 tag sends the page_view, it is then processed by the GA4 client in SGTM and that page_view event is displayed in the preview mode.
With the introduction of the Page View trigger, we now have a default All Pages trigger, that, well, fires on *all* incoming page_view events. But if you want your trigger to be more specific, you can go to Triggers > New (in SGTM) and add additional conditions:
Custom event trigger in server Google Tag Manager
Custom event trigger works in the exact same way as the Page View trigger. The only difference is that you can pick the name of the event on which you want to fire. Where can you find the event names? In the preview mode:
For example, if you want a tag to fire only on user_engagement events, then your trigger configuration should look like this:
Custom trigger vs Custom Event trigger in server-side GTM
The custom trigger is the OG trigger that was introduced together with the launch of SGTM. You can configure it to fire on any incoming request that was claimed and processed by a client.
The custom event trigger (compared to Custom trigger) has one predefined built-in condition, which is the Event Name contains (or Matches Regex) XXXX. You must replace XXXX with the event name that you want to use (e.g. add_to_cart, purchase, or anything else). That event must be visible in the server GTM preview mode right here:
Triggers in Server Google Tag Manager Containers: Final words
Honestly, I wasn’t expecting this kind of guide to appear on my blog. When SGTM was introduced, it had only one trigger and I thought that this is how it will always work. However, it looks like the Google Tag Manager team is adding little time savers here and there to make your work a bit easier.
Interesting, I wonder what will they add in the future