title: Why is Google Analytics event not sent from onSubmit?
body: <p>I'd like to track how often users download files using Analytics' events, but even though the events seem to have been sent, the tracking .gif doesn't seem to be arriving properly.</p>
  
  <p>To download files, users are required to fill out a brief form. The information entered into this form is checked by the function <code>checkSubmit()</code> (which returns <code>false</code> when the entered info is invalid or incomplete, <code>true</code> when the information is good to be submitted). Once submitted, the user is redirected to the file.</p>
  
  <pre><code>&lt;script&gt;
  function checkSubmit() {
      …
      if(dataIsGood) {
          _gaq.push(['_trackEvent', 'Download', 'the_filename.xxx']);
          return true;    //allow the form to submit
      } else {
          _gaq.push(['_trackEvent', 'Form', 'info not okay']);
          return false;   //keep the form from being submitted
      }
  }
  &lt;/script&gt;
  
  &lt;form action="/form/emailcaptureform" method="post" onSubmit="return checkSubmit();"&gt;
  … &lt;/form&gt;
  </code></pre>
  
  <p>In the Chrome console, the <a href="https://chrome.google.com/extensions/detail/jnkmfdileelhofjcijamephohjechhna" rel="nofollow">Google Analytics Tracking Debugger</a> says Download event tracking beacons have been sent, but the console says it <strong>failed to load resource __utm.gif</strong></p>
  
  <p>This happens <strong><em>only</em> with events pushed just before the form is submitted</strong>. <strong>Events work elsewhere</strong> on my site—including the Form event pushed when the form info is no good (in the <code>else</code> block above)</p>
  
  <p>The <a href="http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html#Snippet" rel="nofollow">Analytics snippet</a> seems to be working, accepting <code>_trackPageview</code>s and <code>_trackEvent</code>s.</p>
  
  <p><strong>The request URL for __utm.gif is well-formed</strong>: copy-and-pasting the URL from the gadebug output into the location bar returns __utm.gif without a hitch.</p>
  
  <p>The event is pushed without issue when pushed from another element. For example:</p>
  
  <pre><code>&lt;a href="#" onClick="_gaq.push(['_trackEvent', 'Download', the_filename.xxx']);"&gt;Event!&lt;/a&gt;
  </code></pre>
  
  <p>Pushing the event, pausing for a few seconds, then returning <code>true</code> does not seem to have any effect—beyond adding a pause before submitting the form.</p>
  
  <p>Do you have solutions or suggestions?</p>