Trying to setup a custom JavaScript in GTM where the innerHTML value is checked for X and if it is X fires.
Here's what I have so far but it's not firing correctly
function() {
var el = document.getElementById('ltrNumPlaceholder');
if (el == null) return 0;
return parseInt(el.innerHTML);
}
I also tried this but GTM plains there there is a syntax error on a line that doesn't exist. (GTM error message for the below is: "Error at line 5, character 2: Parse error. ')' expected.")
function(){
var stepNum = document.getElementById('ltrNumPlaceholder').innerHTML;
if(stepNum == 2)return parseInt(stepNum);
};
Thanks for your help in advance.
Trying to setup a custom JavaScript in GTM where the innerHTML value is checked for X and if it is X fires.
Here's what I have so far but it's not firing correctly
function() {
var el = document.getElementById('ltrNumPlaceholder');
if (el == null) return 0;
return parseInt(el.innerHTML);
}
I also tried this but GTM plains there there is a syntax error on a line that doesn't exist. (GTM error message for the below is: "Error at line 5, character 2: Parse error. ')' expected.")
function(){
var stepNum = document.getElementById('ltrNumPlaceholder').innerHTML;
if(stepNum == 2)return parseInt(stepNum);
};
Thanks for your help in advance.
Share Improve this question asked Nov 13, 2014 at 15:14 JPFotozJPFotoz 1051 gold badge4 silver badges15 bronze badges 1- To circumvent the problem you could use a DOM macro for the element with the id "trNumPlaceholder" and then a lookup table macro based on that. – Eike Pierstorff Commented Nov 16, 2014 at 19:26
1 Answer
Reset to default 5To fix the error message, just remove your semicolon at the end of the function (after the closing curly bracket), and that should work.