How do I open Javascript link in new tab?

Google Analytics doesn't register events in IE if link opened in new tab

  • Is there any info on why Google Analytics doesn't register events in IE if the link is opened in a new tab? Google Analytics registers events in IE, unless it's a link opened in a new tab (either by CTRL+click or by right-click/"Open in new tab"). That same link opened in IE in the same tab will register as an event. That same link opened in a new tab in other browsers (FF, Chrome, Safari) will also register as an event. Since (unfortunately) a large percentage of our traffic is still in IE, I've been asked to find info on this problem and possible ways to solve it. I'm not having any luck with it. I've posted to the Google Products forums but it looks like some of those questions aren't getting answered, or aren't getting answered well, so I thought I'd try here too. Any suggestions?

  • Answer:

    Is this for links to other places on your own site? If so, it sounds like IE isn't sending the same headers when opening a new tab as when opening the link in the same tab (my suspicion is that it doesn't populate the Referrer header, or doesn't send the same cookies, specifically). You might install http://www.telerik.com/fiddler and figure out what's different between the requests you see between the two scenarios. Then, once you know what's happening, you can ask a more specific and better answerable question, because right now the answer is "I have no clue." This https://stackoverflow.com/questions/4762254/javascript-window-location-does-not-set-referer-in-the-request-header looks relevant. If it's for links to other sites, then the answer is that browsers (not just IE) routinely bypass Javascript event handlers when opening new tabs, and there's not that much you can do about that aside from modifying the link to go somewhere you do control instead.

johnofjack at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

jeffamaphone

Ah. It's for links to other sites. Thanks!

johnofjack

No problem. It's possible that the reason you're seeing this only in IE is because they're able to fake the new-tab behavior in the other browsers with a click handler that handles the CTRL-click case and uses window.open() to bring up the new tab; in IE, I believe window.open() opens a new window unless the user configures it not to, which is probably undesirable. However, I would expect that all browsers would bypass such handlers if the tab is opened by middle clicking or right-clicking and choosing "Open in new tab" from the menu.

Aleyn

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.