我的网站目前在底部有传统(非异步)Google Analytics跟踪代码。
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + gaJsHost + "stats.g.doubleclick.net/dc.js' type='text/javascript'%3E%3C/script%3E"));
</script>
我计划升级到Universal Analytics跟踪代码。新的跟踪代码是否可以放入正文中,还是应该只按照Google的说明放在头部(标记之前)? 感谢。
答案 0 :(得分:3)
谷歌在Set up the web tracking code
中说Paste your snippet (unaltered, in it’s entirety) into every web page you want to track.
Paste it immediately before the closing </head> tag. If you use templates to
dynamically generate pages for your site (like if you use PHP, ASP, or a similar
technology), you can paste the tracking code snippet into its own file, then include
it in your page header.
我知道有人把它放在身体以及页面底部,所以是的,你可以把它放在体内,如果你愿意的话。它仍然有效。我个人总是把它放在标题中,如果谷歌推荐它,他们必须知道他们在谈论什么。