遵循此处找到的文档:https://developers.google.com/analytics/devguides/collection/gajs/
我在一个空的html文件中做了一个最简单的例子:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXX-2']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
当我使用Google Tag Assistant插件在Chrome中加载页面时,它显示“未检测到HTTP响应”,我在开发人员工具网络标签中看到的是从google下载的html文件加载和ga.js脚本。我在IE中得到了相同的结果,但是当我使用Firefox时,我可以看到它试图从Google获取__utm.gif,这就是我理解它应该可以工作的方式。
我在控制台中看不到任何错误,为什么在IE和Chrome中无法正常工作?
这是整个html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>GA Test</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-X-2']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<p>Testing GA</p>
</body>
</html>
最佳答案
如果您正在区域设置HTML文件中使用跟踪代码(如您所说,该网站尚未启用),则可能是这种情况。
所以,
当您将其发布到实时域时,此跟踪代码将起作用。
可能是如果您添加字符串_gaq.push(['_setDomainName', 'none']);
在字符串_gaq.push(['_trackPageview']);
之前
在您的区域设置HTML中,它将为您工作并发送HTTP响应。
关于google-analytics - Google Analytics(分析)电子商务跟踪“未检测到HTTP响应”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29566288/