#GTMTips: When you click on variables not checked – News Couple

#GTMTips: When you click on variables not checked

A surprisingly common question in forums and communities seems to be why inline click variables look like this undefined In Google Tag Manager preview mode, even if you click around the site.

In this article, I will walk you through some of the reasons why this happens.


Simmer . Newsletter

Subscribe to the Simmer newsletter to get the latest news and content from Simo Ahava right in your inbox!

Tip 104: What to do when click variables are undefined

Here’s the situation: you want to create the click trigger for your tags, but to do that you’ll need to know what values ​​the inline click variables get (eg click categories, click id). Thus, it’s a chick-and-egg case – you can’t create the trigger until you know what to track, and you can’t track it until you create the trigger.

Well, that’s the thing.

You have to create a trigger for click variables to populate them with values.

Variables will not start collecting data until you enable one of the following triggers:

  1. a Click – All Items Trigger – When you want to track clicks on Which an item.

  2. a Click – links only Trigger – When you want to track clicks on Link elements (<a href="...">).

  3. a Submit form Trigger – When you want to track file submissions form element.

  4. that see item Trigger – When tracking a file Vision or appearance for an HTML element.

Naturally, if you want to track clicks, you will need to create a trigger for all items or just links, as clicks are tracked. The only difference is that the latter is more restrictive, as it only tracks clicks on link elements or nested elements within a link node.

So The first thing to check if the click variables are undefined is if you remembered to create the click trigger. The easiest thing to do is to create a simple All Elements launcher with no restrictions.

You don’t even have to add it to a tag. Once the trigger is created, the GTM will start listening for click events.

Click - All Items

Once you enable the launcher, you can enter the preview mode. At this point, any click on your web page should add a file click An item in the preview mode window. by Choose this click item You should see the variables are populated:

Select Click event

Which leads me to the next advice. If click variables are undefined, Make sure the Click event is selected In the preview mode message list. GTM preview mode shows you the values ​​of the variables that were there at the time the file was determinant The message has been processed.

Always avoid correction with summary Selected, because that simply shows you the most recent values. This is irrelevant information if you want to know what values ​​were there when the tag was activated, for example, as you’d need to define the trigger event for the tag to find out.

The last thing to check is whether you have done this incorrectly click a file dataLayer Thus breaking the GTM triggers.

No event to display the page

A clear sign is that there is no “view page” event in dataLayer, as this is automatically generated by the container snippet and will be replaced by the . extension dataLayer. However, if the GTM container can load before the replacement occurs, it may still see the page render event even if it isn’t there from dataLayer. This leaves you with two options to check if this is the case:

  1. open the javascript consoleAnd type window.dataLayer and press enter. The array must be empty or there must be no object in it gtm.js as a value event a key.

  2. open the javascript consoleAnd type window.dataLayer.push(event: 'debug') and press enter. if dataLayer broken, you Will not See an event by name correction It appears in the preview mode message list.

The data layer is disabled

If this is the case, you need to convert this overwriting to a more secure format, essentially a file dataLayer.push(). Follow this article for the steps on how to do that.


If the click variables are undefined, it’s usually because you neglected to create the necessary trigger(s).

However, there are some edge cases where you or your developers have inadvertently overwritten Google Tag Manager dataLayer, which results in the GTM not responding to dataLayer.push() Commands, including those created by triggers.

With the steps in this article, you should have your Click variants populated with useful data in no time!

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button