Onclick="pageTracker._link..." from Google Analytics -- need help with code

I’m using Google Analytics on my site and the site I’m using it on has a section of it that still uses frames. (Yes I know frames are horrible and outdated…but we still need them for this section of our site). Anyways, I’m using the code on some links that go to another URL where I need to use the code for tracking links across multiple domains. So my link looks like this:

<a href=“http://www.otherurl.com” onclick=“pageTracker._link(this.href); return false;” target=“_top”>Go to Other URL</a>

My problem is though that even though I have target=“_top” in the href tag the new URL still loads into the frame itself instead of loading in the whole browser window and leaving the frames pages. I’m thinking that I need to change something in the onclick javascript code. Does anyone know what I can change in the javascript code to make this work and still be able to track my links? I’ve posted this on the Google Analytics help forum but no one was able to help, so thought I’d post it here. If I take out the onclick part the link works just fine. So I know it has something to do with the javascript portion.

Well I got it to work. Instead of framename.document.location I used window.top.location and it works!
Thanks SlickAU by the way for your help.

Wouldn’t framename.document.location open up the link in the same frame? How do I make it so that when the link is clicked it leaves the frames and opens. Not in a new window, just outside the frameset. The equivalent of target=“_top”.

Ahh yes, us old timers remember the heedy days of breaking out of frames

Use top.location.href = document.location.href;

Check out this site if you haven’t already if are trying to track outbound links:

With the function that you add to your head you could modify it to be similar to the following:


<script type="text/javascript">
function recordOutboundLink(link, category, action) {
  try {
    var pageTracker=_gat._getTracker("UA-XXXXX-X");
    pageTracker._trackEvent(category, action);
    setTimeout('[COLOR="Red"]framename[/COLOR].document.location = "' + link.href + '"', 100)
  }catch(err){}
}
</script>

Let us know if you need anymore help