【问题标题】:Google Analytics Script not Firing in IE. No other elements on the page to corrupt the scriptGoogle Analytics 脚本未在 IE 中触发。页面上没有其他元素会破坏脚本
【发布时间】:2012-09-20 20:08:22
【问题描述】:

我有一个页面,上面只有 Google Analytics 代码。它适用于除 IE 之外的所有浏览器,我什至能够在此页面上触发其他脚本;但是,GA 脚本不会触发。我正在使用 Fiddler 来验证它是否正常工作。

缺少什么?这令人沮丧。

IE9 64 位

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-947358-1']);
  _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>

</body>
</html>

【问题讨论】:

  • 你有没有试过用IE中的开发者工具检查ga.js是否加载正确?
  • 您是通过http 还是file 加载页面?
  • 我已经使用了 IE 开发工具和 Fiddler 来尝试验证它是否正确加载。通过httpfile 加载页面时脚本不执行

标签: javascript internet-explorer google-analytics doctype


【解决方案1】:

IE9具有跟踪保护功能—— 如果 google-analytics.com 在跟踪保护列表中,它可能会阻止加载 ga.js。

【讨论】:

  • 感谢您对此的提醒。我检查了一下,它似乎是一个选择加入的功能,所以我认为这不是根本原因。
猜你喜欢
  • 2016-01-25
  • 1970-01-01
  • 2020-04-10
  • 2018-03-20
  • 1970-01-01
  • 1970-01-01
  • 2016-12-08
  • 2021-02-27
  • 2013-11-15
相关资源
最近更新 更多