Google跟踪代码管理器脚本未捕获的TypeError:无法读取未定义的属性“test”

时间:2016-12-29 17:24:38

标签: javascript google-analytics google-tag-manager

我正在尝试在我的网页上实现the Google Tag Manager script但是它会引发错误。我把我的html页面剥离到了简单的地方:

<html>
<head>
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
      new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
      j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
      'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-XXXX');</script>
</head>
<body>
</body>
</html>

但是我仍然看到在conole中抛出以下错误:

Uncaught TypeError: Cannot read property 'test' of undefined
    at <anonymous>:14:12
    at gtm.js?id=GTM-XXXX:57
    at Object.Th (gtm.js?id=GTM-XXXX:59)
    at sf (gtm.js?id=GTM-XXXX:31)
    at uk.B (gtm.js?id=GTM-XXXX:90)
    at ag (gtm.js?id=GTM-XXXX:99)
    at jg (gtm.js?id=GTM-XXXX:39)
    at Array.a.push (gtm.js?id=GTM-XXXX:105)
    at Array.<anonymous> (gtm.js?id=GTM-XXXX:105)
    at Lf (gtm.js?id=GTM-XXXX:34)

The GA Debugger Chrome extension表明脚本仍处于“工作”状态,即所有正确的ga方法都在触发。我只关心这个错误是什么。

注意,我在Firefox和Safari中也遇到了同样的错误(跟踪看起来略有不同,但是它的错误相同):

TypeError: undefined is not an object (evaluating 'tryformurls.test')
    Global Code (Script Element 2:14)
    insertBefore
    (anonymous function) (gtm.js:57:395)
    Th (gtm.js:59:209)
    sf (gtm.js:31)
    (anonymous function) (gtm.js:90:467)
    ag (gtm.js:99:263)
    jg (gtm.js:39:257)
    push (gtm.js:105:388)
    (anonymous function) (gtm.js:105:151)
    Lf (gtm.js:34:198)
    (anonymous function) (gtm.js:106:83)
    Global Code (gtm.js:108)

0 个答案:

没有答案