Google Tag Manager Link Click returns boolean value "false" - google-analytics

I have set up a "linkClick" trigger to track menu clicks. But it shows false instead of the actual text in the Click Text variable. How is it even possible for a string parameter to return a boolean?

I encountered the same problem as you, when setting up a auto-event variable and custom javascript, where return type would always be boolean and result false.
Asking around, there seems to be a problem with Google Tag Manager at the moment, so you are just encountering a bug.
Keep an eye on Google Tag Manager the coming days as it should hopefully be worked out!

Related

GTM and GA4: Access gtm.element.value not working

I have a project that uses GTM and GA4. In GTM I have an event (connected with GA), that needs to track user input (search bar).
The trigger seems to work right - it fires when required. When I look at the dataLayer from the click event (after search input was typed in), I can see that the value of the search bar can be found under: gtm.click.value.
That's why I've created a custom variable. But for some reason the custom variable always returns "" (empty string). I don't understand why, because when I check the dataLayer in my console, I see the right value. I've double-checked, if I'm tracking the right click event - and I do: the gtm.uniqueEventId is the right one.
Can someone tell me what's wrong? How can I access the gtm.element.value?
Try making a Custom JS varialbe and have this in it:
funciton(){
return {{Click Element}}.value;
}
See if it returns the value of your clicked element.

Google Tag Manager - Returning a href from another element when a click tag is fired

I'm working on Google Tag Manager/Analytics for a site, here's an example page that a tag is being fired on:
https://www.forktrucktraders.co.uk/listings/refurbished-combilift-multi-directional-gas/
The tag is fired when the "Send Message" button on the contact form is clicked:
https://imgur.com/a/qTPb3Ci
Right now I've got the event's action returning the URL of the current page the form was sent from, but I'd like to know if it's possible to get the href from the "Visit dealer's website" link on the page, as it would give a faster idea of which dealer the listing is coming from. Probably a long shot to make this happen solely through Tag Manager (if not possibly just a hidden bit of data that just has the dealer's name in on the "Send Message" button) but I'd appreciate any input.
You most certainly can. Off the top of my head something along the lines of the following should work...
It depends on whether you prefer just having the url or breaking it down further.
Just the URL:
Create the following in a custom HTML tag within GTM
<script>
//This selects your desired href:
var dealerURL = document.querySelector(".stm-dealer-image-custom-view a").href;
//This pushes the value into the dataLayer temporarily for use later:
window.dataLayer.push({
event: 'formSubmit',
dealer: dealerURL
})
</script>
Ideally, this should be fired on page load of all your listings pages.
Next create a new User-Defined Variable of the dataLayer var type
within GTM corresponding to dealer, this will store the value to be
pulled through in your event.
Now just change your event action to {{dealer}} (or whatever you
ended up naming the datalayer variable), and this value should be
pulled through in your event.
Getting the dealer name:
Now presuming the href format is always the same across the site you could split this by a delimiter instead:
var dealerURL = document.querySelector(".stm-dealer-image-custom-view a").href;
var dealerSplit = dealerURL.split("/");
var dealer = dealerSplit[4];
The above would leave you with a variable containing the string 'hitec'.
This however is quite prone to breaking if the page path does not always follow the same format, as such it would be better to use RegEx instead.
To answer your specific question, you would need to create a variable to target that specific link element that contains the dealer's website's url. The simplest way is probably to add an id to the <a> element and create a variable in GTM to track it.
I had a quick look at your site and I think you have more problems with the form.
Your even triggers without validating the form, this would lead to extra events.
The event category, action and label could use some work in organizing it to help you analyze the data
You also have a mix of gtag.js and GTM snippet on the page, I would say this is not normal practice, usually, GTM is enough. You can contact me through my profile if you'd like to chat more about it.

Google Analytics returning many "undefined" events

I've got a fairly simple Tag Manager/Analytics set up (firing events on clicks/visibility) and it's working as expected for the tags I've set up myself. However when I check the Analytics page there are thousands of "undefined" tags.
I've had a look at all of the tags I created and none of them should be returning "undefined" as the category/action (the label is "(not set)")
All I need is for the undefined events to be ignored (or even better to stop firing) in Google Analytics, as it's getting in the way of the client analysing the data.
Any help is appreciated
EDIT:
As suggested, here's the only User-Defined variable on the Tag Manager:
https://imgur.com/a/flcCpGo
Here's an example of one of the tags:
https://imgur.com/a/eWM22FB
and here's a tag being fired in the preview mode:
https://imgur.com/a/0ipwqhr
May be some other (hardcoded) event returns 'undefined'?
Try to check in Chrome using «Dev Tools», tab «Network», filter google analytics calls.
And I notice you send 'gtm.click' (string) in field 'Value' that must contain integer.
Turns out this was simply just due to a tag not having a category/action/label that had been paused a while ago, the Analytics timeframe was covering from before when this tag was paused, leading it to show the undefined tags.

Tag parameters only come through on new tab

I'm using Google Analytics via Google Tag Manager. I'm on Chrome and checking tags using Google Tag Assistant.
I've noticed that for many, if not most of the events I have tagged, the parameters will not pass through unless the link or key webpage they are clicking on opens in a new tab.
In HttpFox the result is a NS_BINDING_ERROR or something along those lines.
For example, if you visit this site, you can see there are two means of navigating to the "submit report" page - the CTA on the top right and in the main nav. I'd like to understand how the CTA performs compared to the main nav so have set up events, but the event only fires if I open the links in new tabs.
What does this error mean and what should I do about it?
To get rid of the ns binding error, have the onclick return false - Documentation Here.
In regards to the event not getting passed, I'm seeing in httpfox that the tid (on the event) is UA-34035531-[1-6]. That doesn't look quite right. How are you setting the account id?

Textfield value empty when I fill it with javascript

I am using modalpopup to enter some value in a textfield. After the value is selected in the modalpopup view, the modalpopup is closed and the value takes the appropriate value. Even if the value is displayed in the textfield, the textfield1.text returns an empty string. When I see the source code (html), I see that even the textfield isn't displaying anything; it hasn't really had this value input, because the appropriate html input field hasn't got a value yet.
This is the code I use to fill this textfield:
function CloseRequestModal(s)
{
document.getElementById('<%=txtRequest.ClientID%>').value = s;
var mpu = $find('<%=ModalPopupExtender3.ClientID%>');
mpu.hide();
}
Please help.
I would need to see source HTML cause it looks like you have template language mixed into your javascript but perhaps instead of "textfield1.text" you use "textfield1.value"?
Additionally, you would need to view "generated" source (with a browser plugin) or inspect the node with web inspector on safari/chrome or firebug on firefox in order to see the change that you made with javascript.
i fixed this problem in an alternate way.
even if the value is there (in the textfield), none of the events is fired, to let know the browser / compilator that the value really exists.
so i decided, despite editing the value of the textfield, i store this value in the session too. in this case, the value is displayed for user needed in the interface, and on the other hand i use the value that i stored in the session.

Resources