[英]Error in Custom Google Tag Manager JavaScript
Trying to setup a custom JavaScript in GTM where the innerHTML value is checked for X and if it is X fires. 尝试在GTM中设置自定义JavaScript,在该方法中检查innerHTML值是否为X,如果为X,则会触发。
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 complains there there is a syntax error on a line that doesn't exist. 我也尝试过此方法,但GTM抱怨在不存在的一行上存在语法错误。 (GTM error message for the below is: " Error at line 5, character 2: Parse error. ')' expected. ")
(以下内容的GTM错误消息是:“ 第5行错误,字符2:解析错误。')'。 ”)
function(){
var stepNum = document.getElementById('ltrNumPlaceholder').innerHTML;
if(stepNum == 2)return parseInt(stepNum);
};
Thanks for your help in advance. 感谢您的帮助。
要解决此错误消息,只需在函数末尾(大括号后)删除分号即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.