简体   繁体   English

IE条件注释和Google Analytics(分析)问题

[英]Issue with IE conditional comments and Google Analytics

I have a web-page that starts like so: 我有一个像这样开始的网页:

<!DOCTYPE html> 

<html>      
<head>      
    <!--[if lt IE 10]>
    <script>
        location.href = "http://www.getfirefox.com";
    </script>
    <![endif]--> 

That page gets ~500 pageviews/month and for the last 6 months I had no IE visitors according to Google Analytics. 根据Google Analytics(分析),该页面每月可获得约500次浏览量,在过去的6个月中,我没有IE访问者。 However, a few days ago I got a report of an IE6 visit. 但是,几天前,我收到了有关IE6访问的报告。 How did that happen? 那是怎么发生的?

Did the redirection code in the conditional comment fire to late? 条件注释中的重定向代码是否触发到很晚?
Did Google Analytics code mistakingly identified a non-IE browser as IE6? Google Analytics(分析)代码是否误将非IE浏览器标识为IE6?

You register no IE visits because your script with location.href = ... runs before the Google Analytics code gets a chance to run. 您没有注册IE访问,因为带有location.href = ...脚本在Google Analytics(分析)代码有机会运行之前就已运行。

You could have registered that IE6 visit if 您可以注册IE6访问,如果

  1. IE 6 failed to do the location.href assignment (I've seen problems reported with this) but did run the analytics js code. IE 6无法执行location.href分配(我已经看到过有关此问题的报告),但确实运行了Analytics js代码。

  2. An IE 6 visitor had javascript turned off (in this case they wouldn't run the analytics code either, so wouldn't register a visit) IE 6访问者关闭了javascript (在这种情况下,他们也不会运行分析代码,因此也不会注册访问)

  3. Another browser is impersonating IE 6, eg in the User-Agent string, but doesn't process the conditional comments. 另一个浏览器正在模拟IE 6,例如在User-Agent字符串中,但不处理条件注释。

You can move your conditional comment and the script within it to the end of the page, after the analytics js code if you want Google to count it but still send them off to getfirefox.com 您可以将条件注释和其中的脚本移动到页面末尾,如果您希望Google对其进行计数,但仍将其发送到getfirefox.com,则在分析js代码之后

You can also just say 你也可以说

<!--[if IE]
...

don't test a specific version if you always want to send IE away. 如果您始终想发送IE,请不要测试特定版本。

He had javascript disabled. 他禁用了JavaScript。

Also, nice usability. 另外,很好的可用性。 You know they're not going to download firefox and then come back, right? 您知道他们不会下载firefox然后再回来,对吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM