Adding custom definitions and passing through custom data in Google tag manager

How to add custom definitions and pass custom data to Google Tag Manager

Technical How to add custom definitions and pass custom data to Google Tag Manager

Correctly utilising Google Tag Manager gives you excellent insight into how your users are engaging with your website. But, adding custom definitions and passing through custom data gives you another layer of useful data and insights.

Google Tag Manager or GTM, is a fantastic tool that allows you to track all kinds of events and happenings on your website. Meaning you can measure the effectiveness of the various elements of your websites. Giving you valuable insights on areas of improvement, to achieve your desired results.

Discover how to add attributes to GTM and pass custom data and events to Google Analytics. Providing you with the knowledge to maximise the potential of your tracking capabilities.

 

What are the core components of Google Tag Manager?

 

Within Google Tag Manager, you’ll find that the functionality is split into 3 separate components. This helps to define and manipulate the data to how you need it when creating custom events in Google Analytics 4.

 

Tags

These are snippets of code and allow you to send the data to Google Analytics. Tags are where you set up your custom events and pass the data through accordingly using the “Custom Parameters” tab.

 

Triggers

A trigger in Google Tag Manager will determine where and when your tags are “fired” on your website. They sit and run in the background and wait until specific conditions are met and then allow the tags to pass data.

 

Variables

These are what store and retrieve the data within GTM. These can provide additional information that you wouldn’t normally be able to get from Analytics on its own. Variables are vital in passing custom data in GTM enabling you can track specific elements from your website that you can’t currently.

 

How to add custom event parameters

 

When creating a new event using a tag in Google Tag Manager you’ll notice underneath the “Event Name” textbox there will be a tab labelled “Event parameters”. Here you are able to pass through additional data that you might want to know when you come to analyse the results of the event. For example, you might want to pass through the “Click Text” of a click of a navigation item.

You’ll need to name this parameter. This can be anything you desire so that you can attribute the data to it further down the line. This name will be identified in Google Analytics as a “Custom Definition”. You can also use the icon on the right side of this input field and select the user-defined variable you want to use.

It’s important to note that underscores are used in place of spaces when naming your parameter. this ensures that the data pulls through correctly when you’re viewing the reporting for the custom event.

 

Example:

You could use “click_url” to pass through the URL of the link clicked by the user. Then select the variable data which is passed through as the value into Google Analytics. In this instance, you’d be able to see the most popular route of navigation, and what the click text of the link was.

 

Managing Data Variables

 

GTM gives you the ability to manage what data variables are used in GTM. As not all variables are available upon setting up a property. To see the list, simply click ‘variables’ on the left side menu. The available variables already set up will appear, and you can tick the box to enable them with Google Tag Manager.

 

How to pass custom data into Google Tag Manager: Step by Step

 

1. Modify your website code

To pass custom data, you need to modify your website’s code to include the necessary data layer or JavaScript objects. The data layer serves as a bridge between your website and GTM, allowing you to push relevant information to GTM.

 

2. Define data layer variables in GTM

In GTM, create data layer variables that correspond to the custom data you want to capture. These variables act as placeholders for the incoming data.

 

3. Create triggers and tags

Set up triggers based on specific events or conditions that occur on your website, such as form submissions or button clicks. Then, create tags to process and send the data to your desired destinations, such as Google Analytics.

 

4. Configure variables and data mapping

Configure the variables in your tags to retrieve data from the data layer variables you created in step 3. Map the custom data in the data layer to the appropriate fields in your tags.

 

5. Test and publish

Test your implementation thoroughly to ensure the custom data is being captured correctly. Once you are confident in its functionality, publish the changes in GTM to make them live on your website.

 

Benefits of passing custom data to GTM

 

Adding attributes and passing custom data to Google Tag Manager can significantly enhance your website’s tracking capabilities. By attaching attributes to tags, triggers, and variables, you can customise their behaviour. Making event tracking work for your business, and making them more contextually relevant.

Passing custom data through the data layer also enables you to collect specific information and gain deeper insights into your website visitors’ interactions. Mastering these techniques allows you to optimise your analytics. In turn, you can make data-driven decisions that can propel your business forward.

 

Need support in setting up GTM or passing through custom data, drop us an email at [email protected]

Take a look at our previous work. Explore our team and agency. Learn from our latest insights. Get in touch to begin your journey with us!