这也适用于在页面加载后调用多个 _trackPageview(用于其他记录的操作,例如,跟踪某人何时下载 PDF)
<script type="text/javascript">
var ua_codes = ['UA-XXXXX-1', 'UA-XXXXX-2', 'UA-XXXXX-3']
var _gaq = _gaq || [];
for(i in ua_codes) {
_gaq.push(['_setAccount', ua_codes[i]]);
_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>
<a href="/some_document.pdf" onClick="record_click(this.href);">Read the pdf</a>
<script type="text/javascript">
function record_click(track_url) {
for(i in ua_codes) {
_gaq.push(['_setAccount', ua_codes[i]]);
_gaq.push(['_trackPageview', track_url]);
}
}
</script>