百度+google

百度比较快,google功能全帮我分析..

  1. //Google
  2. <!– Global site tag (gtag.js) – Google Analytics –>
  3. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-11111111-1"></script&gt;
  4. <script>
  5.   window.dataLayer = window.dataLayer || [];
  6.   function gtag(){dataLayer.push(arguments);}
  7.   gtag(‘js’, new Date());
  8.   gtag(‘config’, ‘UA-111111111-1’);
  9. </script>

复制代码

  1. //Baidu
  2. <script>
  3. var _hmt = _hmt || [];
  4. (function() {
  5.   var hm = document.createElement("script");
  6.   hm.src = "https://hm.baidu.com/hm.js?11111111111&quot;;
  7.   var s = document.getElementsByTagName("script")[0];
  8.   s.parentNode.insertBefore(hm, s);
  9. })();
  10. </script>

复制代码

请问我要该怎么整合到一个 JS 里面去,
怎么改。求助大佬。
西藏网友:不要用单独的js调用统计
四川网友:可能记录不全吗
湖北网友:写在一个js文件里不就是在一起了?
重庆网友:引用x.js

  1. document.writeln("<!– Global site tag (gtag.js) – Google Analytics –>");
  2. document.writeln("<script async src=\’https://www.googletagmanager.com/gtag/js?id=UA-11111111-1\’></script>");
  3. document.writeln("<script>");
  4. document.writeln("  window.dataLayer = window.dataLayer || [];");
  5. document.writeln("  function gtag(){dataLayer.push(arguments);}");
  6. document.writeln("  gtag(\’js\’, new Date());");
  7. document.writeln("");
  8. document.writeln("  gtag(\’config\’, \’UA-111111111-1\’);");
  9. document.writeln("</script>");
  10. document.writeln("<script>");
  11. document.writeln("var _hmt = _hmt || [];");
  12. document.writeln("(function() {");
  13. document.writeln("  var hm = document.createElement(\’script\’);");
  14. document.writeln("  hm.src = \’https://hm.baidu.com/hm.js?11111111111\’;");
  15. document.writeln("  var s = document.getElementsByTagName(\’script\’)[0]; ");
  16. document.writeln("  s.parentNode.insertBefore(hm, s);");
  17. document.writeln("})();");
  18. document.writeln("</script>");

复制代码
http://tool.chinaz.com/tools/html_js.aspx
澳门网友:看起来不是很规范

01-18 00:22