title: Google Analytics Timeout (kind of) when Opening New Windows
body: <p>I'm implementing GA on one of our client's sites and we have a contact button that links to an external site.  We want to track the opening of that in GA, and that seemed like it would be easy enough...</p>
  
  <pre><code>&lt;a href="http://www.belowgra.de/blah" id="MyLink" target="_contactPage"&gt;Click Here!&lt;/a&gt;
  
  $('#MyLink').on('click', function(){
      _gaq.push(['_trackPageview', '/contact/blah']);
  });
  </code></pre>
  
  <p>This is how we're tracking all of our other page views and such, but for some reason it chokes in this case. When the link is clicked, it fires as expected and opens in a new window. However, if you take a look at Firebug's net tab, the call to the GA gif never finishes loading (and, curiously, doesn't seem to time out - it's definitely been a few minutes since I started googling and then writing this, and the request in my test window is still running...)</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Also, variations such as opening the window via javascript and preventing the default event / returning false haven't worked either.  I did just find one solution:</p>
  
  <pre><code>function trackIt(){
      _gaq.push(['_trackPageview', '/contact/blah']);
  }
  
  $('#MyLink').on('click', function(event){
      setTimeout(trackIt, 1000);
  });
  </code></pre>
  
  <p>But I don't like the idea of having it in a delayed block - while I can try to cut down the time there, I don't want to run the risk of situations where this won't fire as intended and I'll never know (IE7 - lookin' at you!)</p>