意外的令牌<使用脚本标记

时间:2017-03-25 06:49:18

标签: javascript google-analytics

我仍然从谷歌分析中复制了确切的代码,但在我的浏览器控制台中看到了错误

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-6876886-1', 'auto');
  ga('send', 'pageview');
</script>

上面的代码我输入了ga.js文件。怎么了?我输了。

1 个答案:

答案 0 :(得分:1)

当您将JavaScript放入html时,请将其括在<script>...</script>个标记内。

但是当您在.js文件中编写javascript时,您必须省略这些标记。