<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123-2']);
_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>
從緩存問題
除了(如果我改變了跟蹤ID),還有什麼我需要知道的?它還會起作用嗎?它建議把它放在</head>
之前,我所有的其他JS都在</body>
之前,可以放在那裏嗎?我可以將Google分析放入外部JS嗎?
的可能重複[是否有可能把谷歌分析代碼在外部JS文件?(http://stackoverflow.com/questions/1131079/is-it-possible-to-put-google-analytics-code -in-an-external-js-file) – 2011-03-05 16:06:38