我想使用谷歌广告与我正在工作的Ember网站。然而,如果我只是复制我从Google得到的代码块,我会得到这个错误:
Error: `SCRIPT` tags are not allowed in HTMLBars templates (on line 3)在做了一些搜索之后,似乎有些人也有同样的问题,但我还没有找到解决这个问题的方法。有谁有什么想法吗?
发布于 2016-05-24 12:19:25
将外部脚本放入app/index.html文件中。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>TmpApp</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{content-for 'head'}}
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/tmpapp.css">
{{content-for 'head-footer'}}
</head>
<body>
{{content-for 'body'}}
<script src="assets/vendor.js"></script>
<script src="assets/tmpapp.js"></script>
{{content-for 'body-footer'}}
<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-12345678-1', 'auto'); // get the exact number from your Google Analytics admin screen
ga('send', 'pageview');
</script>
</body>
</html>注意到脚本在content-for 'body-footer'下面了吗?记得使用你自己的谷歌分析代码从你的管理部分在谷歌分析。
https://stackoverflow.com/questions/37403690
复制相似问题