Google跟踪代码管理器-预期的主要表达方式 [英] Google Tag Manager - Primary Expression Expected

查看:72
本文介绍了Google跟踪代码管理器-预期的主要表达方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码:

<script>
    <button type = "button"
    onclick="sce.event('mw_button_click', {
    ...});>
    </button>
</script>

当我尝试在 Google跟踪代码管理器中进入调试模式时,出现错误:

And when i try to enter the debug mode in Google Tag Manager I have an error:

第2行字符4中的错误:Pare错误.预期的主要表达方式.

Error in line 2 character 4: Pare error. Primary expression expected.

有人知道如何解决它并且可以帮助我吗?

Does anyone know how to fix it and can help me?

推荐答案

如果您在script标签内使用button标签,则该标签在GTM中不起作用.相反,您应该使用Javascript或Jquery,如我在下面提到的

If you use the button tag inside the script tag it doesn't work in GTM .Instead you should use Javascript or Jquery like I mentioned below

以下是 https://www.w3schools.com/jsref/event_onclick中的示例.asp .希望这对您有帮助

The below is an example from https://www.w3schools.com/jsref/event_onclick.asp . Hope this helps

//获取按钮,当用户单击它时,执行myFunction document.getElementById("myBtn").onclick = function(){myFunction()};

// Get the button, and when the user clicks on it, execute myFunction document.getElementById("myBtn").onclick = function() {myFunction()};

/* myFunction在添加和删除show类之间进行切换,该类用于隐藏和显示下拉内容*/

/* myFunction toggles between adding and removing the show class, which is used to hide and show the dropdown content */

function myFunction() {
  document.getElementById("myDropdown").classList.toggle("show");
}

这篇关于Google跟踪代码管理器-预期的主要表达方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆