(function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
}

解决方案 »

  1.   

    添加 脚本 相当于 <script  ...
      

  2.   

    Document文档对象是JavaScript中window和frames对象的一个属性,是显示于窗口或框架内的一个文档。描述当前窗口或指定窗口对象的文档。它包含了文档从<head>到</body>的内容
    参考
      

  3.   

    直接写<script src=不就行了为什么还要用createelement
      

  4.   

    直接写<script src=不就行了为什么还要用createelement
      

  5.   

    为什么不在head中直接写入<script src="http://wwwgoogle-analytics.com/ga.js"></script>,而要用异步加载呢,是因为谷歌网站流量分析代码不重要所以先加载主页面代码吗?