使用(异步版本)Google Analytics 跟踪出站链接的官方建议是将跟踪事件推送到队列中,例如:
gaq.push(['_trackEvent', 'Outbound', 'http://foo.bar/']);
setTimeout('document.location = "http://foo.bar"', 100);
将匿名函数推送到 GA 队列中会不会更好,例如:
gaq.push(['_trackEvent', 'Outbound', 'http://foo.bar/']);
gaq.push(function() { document.location = 'http://foo.bar/'; });
在这个setTimeout
版本中,不能保证在重定向发生之前处理事件,而在第二个版本中,它只会在处理完事件后重定向——对吗?