I am successfully tracking pages on my site to report to two Google Analytics accounts, however, I can't get the outbound link tracking to track the events in Google Analytics accounts (it's not tracking in either). Any ideas why the recordoutbound link function isn't working? Below is my code:
<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>