我在我的约会网站上使用google_tag_manager进行分析,我已经看到了关于如何实现google_tag_manager的基本教程,...and从控制器生成了代码,并在我的标记...still中显示了错误。
它指出了以下错误:
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);这是我的标记
<%@ 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>如果我删除最后一个脚本部分
<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>错误熄灭。我找不到任何好的参考资料是什么导致了这个问题..
任何建议都会有帮助。
发布于 2014-08-05 15:15:37
如果gtm加载后的代码片段也在跟踪代码,那么您应该将它作为javascript代码片段插入到加载的事件中,比如gtm中的gtm.load。
https://stackoverflow.com/questions/25132403
复制相似问题