title: Google Analytics pageTracker function doesn't work when loaded via AJAX
body: <p>I posted on this a while ago, and have since done more research and advanced the problem, but I still don't have a solution...</p>
  
  <p>I have a site (www.seatgeek.com) where a lot of links are loaded via AJAX.  When a user clicks on one of these links I want to count it as a goal, so I've tried attaching pageTracker._trackPageview() to the links' onClick attribute.  But GA isn't recording these clicks, and I have no idea why.  Here's the code for one of these links:</p>
  
  <pre><code>&lt;a href="&lt;?php echo $tickets[$x][3] ?&gt;" target = "_blank" class="buyTicketsLink" onClick="pageTracker._trackPageview('/outgoing/event4.php');"&gt;BUY TICKETS&lt;/a&gt;
  </code></pre>
  
  <p>I've tried the above code in situations where the link is not loaded via AJAX and it works fine, so it's definitely a problem specific to AJAX.  Also, in my attempts to solve this problem I've also tried adding the onclick events programmatically, e.g.:</p>
  
  <pre><code>&lt;script&gt;
  function attach_goal_tracking() {
  var links = document.getElementsByClassName("buyTicketsLink");
  for(var i=0; i&lt;links.length; i++) {
  links[i].onclick = record_goal;
  }
  }
  
  function record_goal() {
  pageTracker._trackPageview('/event/outgoing');
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>This doesn't work either.  But when I add a test alert box to the record_goal() function, it's clear that the function is getting run.  For example, if I change the function to this:</p>
  
  <pre><code>function record_goal() {
  alert('Hello');
  pageTracker._trackPageview('/event/outgoing');
  }
  </code></pre>
  
  <p>Then the 'Hello' alert box displays when a link is clicked.  But the pageview to '/event/outgoing' still is not recorded.</p>
  
  <p>I'm completely baffled by what might be causing this.  Any advice would be greatly appreciated.</p>