首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ReferenceError:未定义google_tag_manager

ReferenceError:未定义google_tag_manager
EN

Stack Overflow用户
提问于 2014-08-05 14:26:29
回答 1查看 3.6K关注 0票数 1

我在我的约会网站上使用google_tag_manager进行分析,我已经看到了关于如何实现google_tag_manager的基本教程,...and从控制器生成了代码,并在我的标记...still中显示了错误。

它指出了以下错误:

代码语言:javascript
复制
Reference Error: google_tag_manager is not defined


haw_snowplow("newTracker", "", "d1663cp6879lbv.cloudfront.net", { appId: "dating", platform: "web", cookieDomain: "howaboutwe.com", encodeBase64: !0, contextVendor: "com.howaboutwe" }); haw_snowplow("setUserId", google_tag_manager["GTM-NPFN82"].macro(6)); haw_snowplow("trackPageView", null);

这是我的标记

代码语言:javascript
复制
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body class="unified-dedicated_dating_facebook">
    <noscript>
        <iframe src="//www.googletagmanager.com/ns.html?id=GTM-NPFN82" height="0" width="0"
            style="display: none; visibility: hidden"></iframe>
    </noscript>
    <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 = '//www.googletagmanager.com/gtm.js?id=' + i + dl;
            f.parentNode.insertBefore(j, f);
        })(window, document, 'script', 'dataLayer', 'GTM-NPFN82');
    </script>
    <script id="" type="text/javascript">
        (function(a, e, f, g, b, c, d) {
             a[b] || (a.GlobalSnowplowNamespace = a.GlobalSnowplowNamespace || [], a.GlobalSnowplowNamespace.push(b), a[b] = function () { (a[b].q = a[b].q || []).push(arguments) }, a[b].q = a[b].q || [], c = e.createElement(f), d = e.getElementsByTagName(f)[0], c.async = 1, c.src = g, d.parentNode.insertBefore(c, d))
        })(window, document, "script", "//d1fc8wv8zag5ca.cloudfront.net/2/sp.js", "haw_snowplow");
        haw_snowplow("newTracker", "", "d1663cp6879lbv.cloudfront.net", { appId: "dating", platform: "web", cookieDomain: "howaboutwe.com", encodeBase64: !0, contextVendor: "com.howaboutwe" }); haw_snowplow("setUserId", google_tag_manager["GTM-NPFN82"].macro(6)); haw_snowplow("trackPageView", null);
    </script>
</body>
</html>

如果我删除最后一个脚本部分

代码语言:javascript
复制
<script id="" type="text/javascript">
    (function(a, e, f, g, b, c, d) {
         a[b] || (a.GlobalSnowplowNamespace = a.GlobalSnowplowNamespace || [], a.GlobalSnowplowNamespace.push(b), a[b] = function () { (a[b].q = a[b].q || []).push(arguments) }, a[b].q = a[b].q || [], c = e.createElement(f), d = e.getElementsByTagName(f)[0], c.async = 1, c.src = g, d.parentNode.insertBefore(c, d))
    })(window, document, "script", "//d1fc8wv8zag5ca.cloudfront.net/2/sp.js", "haw_snowplow");
    haw_snowplow("newTracker", "", "d1663cp6879lbv.cloudfront.net", { appId: "dating", platform: "web", cookieDomain: "howaboutwe.com", encodeBase64: !0, contextVendor: "com.howaboutwe" }); haw_snowplow("setUserId", google_tag_manager["GTM-NPFN82"].macro(6)); haw_snowplow("trackPageView", null);
</script>

错误熄灭。我找不到任何好的参考资料是什么导致了这个问题..

任何建议都会有帮助。

EN

回答 1

Stack Overflow用户

发布于 2014-08-05 15:15:37

如果gtm加载后的代码片段也在跟踪代码,那么您应该将它作为javascript代码片段插入到加载的事件中,比如gtm中的gtm.load

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25132403

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档