title: How do I log a MixPanel event when a user clicks a link?
body: <p>I'm trying to log an event in MixPanel when users click a certain type of link. I'm using JQuery to do it unobtrusively and as far as I understand I need to add a callback function to take the user to URL after the event has been logged.</p>
  
  <p>This is the code I'm using:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $("#more-posts").click(function() {
          event.preventDefault();
              mpq.track("More Posts", function(){
                  window.location = $(this).attr("href");
              });
      });
  &lt;/script&gt; 
  </code></pre>
  
  <p>Unfortunately this neither takes the user to the page nor logs the event, but I see no errors in the Javascript console in Chrome. </p>
  
  <p>Any ideas what the problem may be?</p>
  
  <p>Update: Also tried this code based on suggestions in the comments:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function go_to_link(link) {
          window.location = link;
      } 
      $("#more-posts").on("click", function(event) {
              event.preventDefault();
              mpq.track("More Posts");
              setTimeout("go_to_link($("#more-posts").attr("href"))", 2000);
      });
  
  &lt;/script&gt; 
  </code></pre>
  
  <p>It now redirects to the correct link, but still doesn't log an event.</p>