GOOGLE TAG MANAGER: TRIGGERS
Variables & DATA LAYERS
https://anythingseo.wordpress.com/2018/02/12/googletag-manager-triggers-variables-data-layers/
A few days ago we provided an introduction to Google Tag Manager (GTM). On this post, we dig deeper into the structure of tags and how they work without being too technical. Before working with tags and GTM, there are a few main concepts you will need to be acquainted with. Though GTM can be used to manage tags in AMP site and mobile apps too, let’s focus on using GTM for the web.
CONTAINERS As the name suggests, containers work like a folder that holds all the tags for your site. The first thing you need to do is to create a container which GTM assigns a code to. The code is added to the source code so that it will be displayed on each page of the site. After this is done, you will be able to manage tags in GTM as needed.
TRIGGERS Like mentioned above, tags have specific purposes. Tags are like bullets; it fires in a direction when triggered. Triggers in this context are comparable to rules. It tells when a tag should fire. The basic components of triggers are events and filters. You need to select an event before you set up your filter. Also, note that a tag must have at least one trigger to fire. It is important to note that a tag will fire when one of its triggers are met. If you need to exempt a few pages, it is advisable to set up a trigger that blocks or overrides that trigger.
Types of Trigger events include: 1. Pageview (web) – use this event for anything you want to fire right away 2. Clicks (web) – use when you like to fire a Trigger for when a visitor clicks on a link or other page elements but not for form submissions. 3. Element visibility (web) – use this trigger to fire tags when an element or elements become visible resulting from actions such as loading a page, scrolling, switching to a background tab in the browser window, etc. 4. Form submission (web) – select Form to fire a tag when a form is submitted by the user. 5. History change (web) – Use this to fire a tag when the URL fragment or hash changes. This trigger is useful in tracking virtual pageview 6. JavaScript error (web) – Use this trigger to fire tags for when an uncaught JavaScript exception occurs (using window.onError) 7. Scroll depth (web) – use this trigger to fire tags depending on how far the user has scrolled on the page; the tag gives you an idea who among your site visitors are engaged in-depth with any of your pages 8. Timer (web) – Use these triggers to send events to Tag Manager at specified intervals. Be sure to specify a limit (in this case, the maximum number of times to fire the event) 9. Custom events (web & mobile) – Use this type of event to track interactions on your site or mobile app that can’t be triggered using standard methods. 10. YouTube (web) – Use this trigger to fire tags for various interactions with embedded YouTube videos on your sites.
VARIABLES Variables contain values that a trigger needs to evaluate if it should fire or not. The tag checks the value of the variable vs what is defined in the trigger and fires if the variable was able to meet the condition. Tags also use variables to collect data for the data layer like when a person adds a specific amount of product to their shopping cart. These variables are reusable in different tags. If you need to use the variable more than once, you can create them in GTM with ID numbers. The most common types of variables have been builtin by Google for easy access in GTM. After you’ve chosen a built-in trigger, you will be able to configure its settings. You may need other variables that aren’t built in the regular container; you can customise a user-defined variable. On the GTM Dashboard, click “Variable” found at the left side of the menu
DATA LAYERS A data layer is an ideal way to keep all the information that tags need to know if they should fire. It eliminates the need for tags to search through HTML to find the information they need (which takes longer for them to fire). This way, GTM helps improve the site speed. It also avoids the instances of broken HTML tags when a site’s HTML structure changes. If you are ready to go deeper into learning about tags and their implementation, here’s a link to Google’s help guide to Tag Managers with examples of detailed Trigger configurations.