Ros Ros - 11 months ago 66
Javascript Question

Google Analytics - Record Outbound Links - open new window

I have used the following link to record outbound links through google analytics. Is it possible to open the link in a new window?

<script type="text/javascript">
function recordOutboundLink(link, category, action)
try {
var myTracker=_gat._getTrackerByName();
_gaq.push(['myTracker._trackEvent', category , action ]);
setTimeout('document.location = "' + link.href + '"', 100)

<a href="" onClick="recordOutboundLink(this, 'Outbound Links', '');return false;">

Answer Source

edit, I forgot to add target="_blank":

I would do it this way tracking outbound links:

<a href="" target="_blank" onclick="_gaq.push(['_trackEvent','outgoing_links',''])">Link Text</a>