In a nutshell, the Google Tag Manager code has four main functions
- Container of tags
- Rules Engine
- Event listener – user or page actions
- Tag activator.
- Tag Container – As mentioned in the “What is a Tag and a Tag Manager” section, all the tags are configured within Google Tag Manager interface and are used as needed. Google Tag Manager code on the page is the container that pulls and uses the tags as needed.
- Rules Engine – In Google Tag Manager, you define a set of rules that determine when and which tag(s) to trigger (fire).
- Event Listener – Google Tag Manager code on the webpage actively listens to user or page interaction on the site. These interactions are known as events. Almost any user or page interaction on a webpage can be captured by Google Tag Manager. Example of such action are page load, link clicks, button clicks, page scroll, form fill, video play etc. These actions are also called triggers.
- Tag Activator – When a condition, as specified in the rules, is met then Google Tag Manager fires the tag that is defined in that rule.
Let’s take an example to see how this works:
- Container – Contains Google Analytics Event Tracking tag.
- Rule – Fire Google Analytics Event Tracking tag when a button on a page is clicked.
- Event Listener – Listens for events on the page and evaluates them based on the rules. In this case, the rule is looking for a button click on a page. When a button is clicked then it trigger Tag Activation.
- Tag Activation – Fires Google Analytics event tracking tag
Follow this series of posts and learn Google Tag Manager – step by step.
Enroll in our course
- Google Tag Manager (GTM) Online Training Course – From Zero to Hero
- Google Tag Manager Advanced Applications