How does Google Tag Manager extract tracking data from datalayer?

Member

by virginie , in category: SEO Tools , a year ago

How does Google Tag Manager extract tracking data from datalayer?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

2 answers

by naomi_cronin , a year ago

@virginie 

Google Tag Manager (GTM) uses a data layer to extract tracking data from a website. The data layer is a JavaScript object that contains information about the user, their behavior, and the context of their visit to the website. When the data layer is implemented on a website, it can be used to trigger tags, which are snippets of code that perform specific actions, such as tracking user behavior.


To extract tracking data from the data layer, GTM uses built-in variables and custom variables. Built-in variables are pre-defined variables that are automatically populated by GTM with data from the data layer. Custom variables, on the other hand, are variables that you define in GTM and populate with data from the data layer.


Here's a step-by-step process for how GTM extracts tracking data from the data layer:

  1. The data layer is implemented on the website using JavaScript code.
  2. When a user interacts with the website, data about their behavior and context is added to the data layer.
  3. GTM is installed on the website, and the GTM container code is added to the website's header.
  4. When a user interacts with the website, GTM reads the data in the data layer and populates built-in variables and custom variables with relevant data.
  5. Tags are created in GTM that are triggered by specific events, such as when a user clicks on a button or submits a form.
  6. When a tag is triggered, GTM uses the data in the built-in and custom variables to populate tracking parameters, such as page views, button clicks, or form submissions.
  7. The tracking data is then sent to third-party analytics tools, such as Google Analytics, for analysis and reporting.

Member

by drew , 4 months ago

@virginie 

The specific steps GTM follows to extract tracking data from the data layer are as follows:

  1. The data layer is implemented on the website using JavaScript code. This code initializes the data layer and defines its structure. For example, it may include information about the user's interactions, page details, or e-commerce data.
  2. When a user interacts with the website, data about their behavior and context is pushed to the data layer. For example, when a user adds a product to their cart, the data layer may be updated with information about the product, price, and quantity.
  3. GTM is installed on the website by adding the GTM container code to the website's header or footer. This code typically loads asynchronously and doesn't block the rendering of the webpage.
  4. When a user interacts with the website, GTM reads the data in the data layer and populates built-in variables and custom variables with relevant data. Built-in variables are predefined by GTM and automatically capture common data from the data layer, such as the page URL or the referrer. Custom variables, on the other hand, need to be configured by the user in GTM and populated with specific data from the data layer. This can be done using GTM's data layer macros.
  5. Tags are created in GTM that are triggered by specific events or conditions. For example, a tag may be triggered when a user submits a contact form or when they view a specific page. These tags can contain various tracking codes, such as analytics tracking codes, conversion tracking codes, or remarketing tags.
  6. When a tag is triggered, GTM uses the data in the built-in and custom variables to populate tracking parameters. This involves mapping the data from the data layer to the appropriate fields in the tracking code. For example, if a user submits a form, GTM may extract the form data from the data layer and send it as an event to Google Analytics.
  7. The tracking data is then sent to third-party analytics tools, such as Google Analytics, for analysis and reporting. This is done by firing the necessary tracking codes or APIs provided by these tools. The data can include information like page views, clicks, conversions, or any other relevant user interactions.


By utilizing the data layer and GTM's capabilities, tracking data can be efficiently extracted and sent to various analytics platforms without the need to directly modify the website's code.