Google Tag Manager (GTM) is a piece of software that helps site owners organise their tracking more efficiently. It’s designed to work better when deployed alongside customised data layers as they allow additional information to be passed on to GTM.
For more background on Google Tag Manager, check out our beginner’s guide to getting started with GTM.
The easiest way to think about data layers is in comparison with the application layer and the experience layer. The experience layer is what a user sees when they visit your website (e.g. text and images), and the application layer is the code that runs your website and its functionalities such as videos and responsive display.
The information contained in a data layer is varied depending on its purpose and can have simplistic values or multitudes of data points. The information is often related to characteristics of a page, for example, whether it’s a blog post or a product page.
Marketers can use the information stored in a data layer to set up actions based on certain conditions, which is particularly useful for ecommerce sites. In some instances, this can be as simple as triggering a pop-up asking a user to subscribe to an email or call upon more complex mechanics such as triggering abandoned cart emails.
GTM can use the data stored in a data layer to gather particular pieces of data from your website and to analyse additional conditions and actions (e.g. account creations). With information to hand, more complex firing conditions can be implemented depending on the user. For example, if a user has added items to their cart, you can create simple responses to fire from the data layer to prompt the user to complete their transaction.
Pushing data to an active data layer can be done by following these two steps:
If you aren’t comfortable adding the data layer directly to the source code (as the first step of this process requires), you can forgo this step, but it may mean that your website takes slightly longer to start pushing the data to Google Analytics.
The data layer snippet added directly to your website’s source code as per step one should look something like this:
Here’s another example of a data layer with additional user details specified:
The second step enables you to track additional information regarding a user’s actions on your site such as information on a product added to a cart. It allows you to perform more accurate analysis of your data by considering information such as the value of products added to a cart or the category of products added to a cart.
You can add up to 10 lines of code here to create more complex triggers based on factors such as user location. If you are working with a developer to add this code to your website, ensure that the data is pushed at the right point. For example, if you are capturing data on form submission, the trigger should come after the form is submitted.
Once this is complete, you should use GTM’s Preview Mode to test if the data layer has been coded successfully. To enable the data layer, head to the GTM Triggers tab and select “New”. Next, select “Custom Event” as the trigger type and ensure that the trigger is set to fire for “All Custom Events”.
Creating the trigger isn’t quite the final step, as you’ll also need to create a variable to collect the data when the trigger is fired. The easiest way to think of variables is as another stepping stone to push the data to Google Analytics once a condition has been met to set off the trigger; the data won’t be sent automatically without the variable. To create a new variable, head to the GTM Variables tab, click “new” and then enter the data layer variable name (e.g. “form.submission.action”).
Being able to implement data layers into GTM is crucial for your website, especially if many pages have been created with goals that fall outside the traditional parameters of Google Analytics. By getting to grips with data layers, you can accrue valuable information regarding user behaviour on your website and take a step closer to fully understanding how people interact with your site.
Want to be at the top of the search ranks? How about a website that’ll give your audience a great experience? Or maybe you’re looking for a campaign that’ll drive more leads? Get in touch to find out how we can help.