Google建議在關閉</head>
之前放置Google Analytics(分析)腳本。Google Analytics(分析)應該放在HTML頁面的頭部還是底部?
但是,我寧願將其與其餘的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>
錯過了[某件事](http://support.google.com/analytics/bin/answer.py?hl=en&answer=1008080) – 2012-08-09 18:40:39