Google跟踪代码管理器(GTM)错误。预期的主要表达

时间:2018-11-30 19:44:58

标签: javascript html object webpage

我一直收到此错误:第5行,字符2:分析错误。预期的主要表达方式

这是自定义HTML的外观:

<script type="text/javascript">

//paste your Tawk embed code here, without Script tags

<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/5a2863145d3202175d9b6c41/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>

有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

您的原始代码中还有第二个<script>标签,该标签无效。它应该看起来像这样:

<script type="text/javascript">

    //paste your Tawk embed code here, without Script tags

    var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
    (function(){
    var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
    s1.async=true;
    s1.src='https://embed.tawk.to/5a2863145d3202175d9b6c41/default';
    s1.charset='UTF-8';
    s1.setAttribute('crossorigin','*');
    s0.parentNode.insertBefore(s1,s0);
    })();

</script>