Login

What Is Google Tag Manager? Part Three

Written by 5 minute read

If you have read part one and two of this series you should now have a great understanding of GTM set up.

 In this part we will focus on the executive power of rules/triggers. 

So what are triggers?

In the previous versions of GTM triggers were referred to as rules, however in the new version the terminology has changed, it’s called triggers now and not rules.
Triggers have become a more integral part of the tag creation workflow, and as such have far more significance in the user interface than before.

Triggers are attached to a tag and they govern if a tag is fired or not fired. If you don’t set any triggers then the tag will not fire. The improved workflow makes it impossible for you not to notice them as you may have with rules in the previous version, now before you can save the tag you get prompted to add a trigger.

tablet

Like rules, Triggers dictate when tags are ‘fired’ from our container. Similarly to rules, Triggers can have one or many conditions on which to fire, but unlike rules, all Triggers require you to start by choosing an event.

Triggers need events to fire? What do you mean by events?

In short a trigger is in itself an event so when you select a trigger you’re essentially selecting an event for your tag to fire. Let’s have a closer look…

Trigger Types

All tags firing in Google Tag Manager are event-driven. Anytime an event is registered by Google Tag Manager, triggers from the container are evaluated and tags are fired accordingly. No tag can be fired unless an event occurs.

An event can be a page view, a click on a button, a form submission, or any custom event that you define. Google Tag Manager has 6 built-in event types plus a custom event option.

The first step in setting up a trigger is to select an event type to associate with it.

The built-in events include:

tablet

So me looking at a page is an event that could fire a tag, is that why you call it page view?

Correct, this event corresponds to the rendering of a page in the user’s browser. However, this event can be further configured, as you can see above we have more options under the Page View section to tell Google Tag Manager if the tag should be fired immediately when the browser starts parsing the page (Page View) or after the browser has finished constructing the full page DOM (DOM ready), or after the page has been fully loaded, including embedded resources such as images and scripts (Window Loaded).

Adjusting the timing of a page view based trigger can be helpful if your tag is using DOM or JavaScript variables to capture dynamic values. All page view based tags that interact with the DOM to populate variables should use DOM Ready as the trigger type to ensure the variables are consistently set.

But that would make the tag fire all the time a page is viewed what if I only want it for a specific page?

You can further configure your trigger to be active based on certain conditions, in the new UI, we have two types of scenarios that allow us to further configure and control how the trigger should work: All Pages and Some Pages.

tablet

In the Fire On step, you specify the other conditions you want to take place before any tag that uses this trigger fires.

Remember, in the new GTM version you do not need to specify the Event condition any more, as it’s implied by the trigger type. If you choose some <event type>, you will need to specify the other condition(s) for your tag to fire. These can be anything you like, such as data layer variable values, page path matches, etc. As before, you can specify multiple conditions, but if you do, remember that every single one of these conditions must be met for your tag to fire. There’s no ‘either-or’ relationship here. Conditions are final.

tablet

And that’s it. If you’re in the tag creation workflow, you will now return to your tag, where you can add other triggers.

Best Practices

Sometimes triggers, when configured improperly, can cause unexpected results. When setting up your triggers, please consider the following guidelines:

Test your triggers with Preview mode

It is important to test your triggers especially form and link triggers before publishing them to your site. These triggers can break if another JavaScript event interrupts the process. A common culprit is that another script returns false before the form or link trigger is reached, preventing those triggers from ever firing. Use Preview mode to see if your tags aren’t firing or if form submissions aren’t being sent properly.

So no exceptions for these rules?

Of course there’s always an exception to a rule  and in this case adding exceptions is simple enough. Just click Create Exception and choose a trigger which will block the firing of the tag. With exceptions, blocking triggers will always win against firing triggers.

However, blocking triggers always need a firing trigger with the same underlying event, otherwise they’re useless. This is because when an ‘event’ key is pushed into the data Layer, the blocking trigger can only block a trigger which fires on the same ‘event’, since they are evaluated at the same time against the same value of the ‘event’ key (complicated, I know!). But for more on triggers have a look at the official GTM documentation here.