【发布时间】:2011-07-19 05:38:27
【问题描述】:
Google 建议在关闭 </head> 之前放置 google 分析脚本。
但是,我更愿意将它与我的其余 javascript 组合在一起,这些 javascript 现在都放在一个缓存的外部文件中,该文件加载在我的 HTML 文件的底部。我可以按我的方式做吗?如果是这样,那么我有什么风险/将下面的代码放在 HTML 的底部而不是头部的成本是多少?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22180365-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
【问题讨论】:
-
错过了something
标签: javascript html google-analytics html-head