Key Points 🔑

1. The Google Tag Manager Data Layer is essential for advanced event tracking; without it, much tracking would not be possible.

2.Getting started with the Data Layer can be challenging, but by starting small and practicing, your skills will improve.

3.TAGGRS offers specific plugins and addons for various CMS platforms to facilitate the implementation of a Data Layer.

4.For an effective setup, it is essential to thoroughly test your Data Layer, variables and triggers in Preview Mode.

Before you start

Before we dive deeper into the Google Tag Manager Data Layer, it’s important to understand some key terms:

  • Google Tag Manager : Tool for managing tags without direct code changes on your website.
  • Variables : Store data used by tags and triggers within GTM.
  • Tags : Pieces of code that perform specific actions, such as collecting data or tracking conversions.
  • Triggers : Determine when and under what conditions a tag should fire.
  • Preview Mode : A GTM feature that allows you to test tags and triggers before they go live.
  • dataLayer.push(): JavaScript function used to send data to the Google Tag Manager Data Layer for tracking purposes.

Do I need a data layer?

Ever wondered if your website needs a Data Layer? If you want to measure basic interactions like form completions, which GTM can often detect directly (captured by the Google Tag ), a Data Layer might not be necessary. This is especially true for standard B2B events, which can be managed via GTM’s built-in variables.

To determine which built-in events the Google Tag can automatically pick up, go to GTM and look under Variables for Built-in Variables which you can enable by clicking Configure . Select the variables that are relevant to your tracking needs here.

Watch the video below to see what these built-in variables look like in Google Tag Manager’s preview mode.

However, if you want to track more advanced events, such as e-commerce related activities that are not recognized by GTM by default, adding a specific Data Layer to your website is necessary.

What is a Data Layer?

One of the most common mistakes when configuring  Server Side Tracking  is not having a (good) data layer. This can lead to incomplete or inaccurate data collection, leading to unreliable analysis and insights.

A Data Layer structures all the data coming from your website, which can then be used in Google Tag Manager for variables, tags and triggers. In practice this means that for every action on your website, such as a purchase, the Data Layer registers this including specific information such as product name, price and quantity. Although this is often done via JavaScript, the Data Layer is more of a conceptual structure for storing data than an actual piece of code.

In summary, a Data Layer helps keep your website data organized and accessible for analysis and marketing, eliminating the need to manually collect or enter data every time.

How Google Tag Manager Uses the Data Layer

Google Tag Manager (GTM) uses the Data Layer to monitor actions on a website. For example, when a user adds a product to the cart, the Data Layer captures this event. GTM then detects this activity via the Data Layer, which results in the firing of a specific trigger. This trigger is associated with a tag that is configured to fire when a product is added, ensuring that the appropriate data is collected without the need for manual changes to the website code.

What does this data flow look like in practice?

To understand how the data flow works, let’s take the example of measuring a GA4 purchase on a website. The process starts when a user makes a purchase on the website. This action and the associated data are stored in a structured manner in the Data Layer. Within this Data Layer are variables that record specific details of the purchase, such as product information, price and quantity.

These variables are then used to set triggers. A trigger is a condition that determines when a tag should fire. In this scenario, a trigger is set to respond to the purchase action, identified by the relevant variables from the Data Layer.

Based on this trigger, a specific tag can then be created and configured, such as a GA4 purchase tag. This tag will fire when the trigger conditions are met, i.e. when a purchase occurs. This allows the purchase action to be accurately measured and recorded within GA4.

What kind of Data Layer do I have?

Regarding the contents of your Data Layer: if you don’t find any e-commerce related data, it could mean that your Data Layer is not configured for this type of data collection. To determine what type of Data Layer you have, you can use GTM’s preview mode. Standard built-in data is shown here, and if you .ecommercesee , for example, it indicates a Data Layer that is set up according to the GA4 protocol.

From Data Layer to Variable

When data is pushed to the Data Layer, Google Tag Manager does not automatically recognize it (outside of, for example, the build in variables). This means that this data is not directly usable within GTM. Your Data Layer can contain a wide range of information, from user data to page information, but without additional configuration this data will not be visible in the Variables section of the Preview and Debug tab, making it impossible to use directly in your tag management.

In order to access this valuable data, it is necessary to create a Data Layer Variable for these data points within GTM. This is done by creating a new Data Layer Variable and entering the exact name of the key you want to extract from the Data Layer.

It is important to remember that data can be stored in different structures within the Data Layer. Therefore, you need to take into account some additional rules when making this data accessible.

How to make sure tag is fired based on a trigger

Once we have set up the variables, we need to create the corresponding triggers. To convert an “event” into an actual trigger that fires a tag, you use a Custom Event Trigger in Google Tag Manager:

1.Go to ‘Triggers’ and click on ‘New trigger’.

2.Select the ‘Custom Event’ type.

3.Enter the exact value of the “event” key you set in your Data Layer push, note that this is case sensitive.

Testing Testing Testing

Make sure your setup is tested. To effectively test your data layer setup:

1.Check your Data Layer : Use tools like Google Tag Assistant or preview mode to verify that your Data Layer is present and contains the correct data.

2.Variables and Triggers : Make sure your variables are correctly retrieved from the Data Layer and that the triggers are set up correctly.

3.Use Preview Mode : Test your tags and triggers in GTM’s Preview Mode to see if they fire as expected.

4.Server Preview Mode : For server side tracking, use Server Preview Mode to check if the server-side tags are working correctly.

Make sure every step is done correctly for a reliable tracking setup. Also check out our comprehensive guide to testing your Server Side Tracking configuration .

FAQ Google Tag Manager Data Layers

How do I fire a tag with a dataLayer.push()?

In order for a tag to be fired at the time of a dataLayer.push(), the action must contain a key named “event”. If this key is missing, a message will only be displayed in Preview and Debug mode, but the tag will not be fired.

What data should I add to the Data Layer?

The data you add depends on what you want to measure. For sales measurement, order ID, total amount, shipping costs, taxes, and coupons are valuable. For tracking login activity, user ID and login method are useful.

Do I need a separate Data Layer for server side tracking?

No, for server side tracking you use the same Data Layer as for client side tracking.

Are there standard names for events and parameters in the Data Layer?

No, you can name events anything you like, such as “login”, “log in”, “log_in”, etc. Parameters can also be named freely, unless you are implementing specific data structures such as Enhanced Ecommerce via GTM, which have strict naming rules. For other situations, parameter names can vary at your discretion.

I need custom data, but find it difficult to get into technical details. What can I do?

You can send documentation and guides to your developer and then check their implementation via GTM Preview and Debug mode to make sure everything is set up correctly. We at TAGGRS also offer implementation. For this you can fill out this contact form .

Saifur Shahin

🥇Certified Web Analytics & Server Side Tracking Specialist