我成功地跟踪了我网站上的页面以向两个 Google Analytics 帐户报告,但是,我无法获得出站链接跟踪来跟踪 Google Analytics 帐户中的事件(它也没有跟踪)。为什么记录出站链接功能不起作用的任何想法?下面是我的代码:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1xxxxxx-x']);
_gaq.push(['_setDomainName', 'mysite.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
_gaq.push(['b._setAccount', 'UA-2xxxxxx-x']);
_gaq.push(['b._setDomainName', 'mysite.com']);
_gaq.push(['b._setAllowLinker', true]);
_gaq.push(['b._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);
})();
function recordOutboundLink(link, category, action) {
try {
var onePageTracker = _gat._getTracker("UA-1xxxxxx-x");
var twoPageTracker = _gat._getTracker("UA-2xxxxxx-x");
onePageTracker._trackEvent(category, action);
twoPageTracker._trackEvent(category, action);
setTimeout('document.location = "' + link.href + '"', 100)
} catch (err) { }
}
</script>