title: Triggering a javascript event without a one pixel .gif
body: <p>I am trying to trigger an event in Javascript to be tracked in Google Analytics when a form is submitted and the 'thank you' message (not a new 'thank you' page) is shown.</p>
  
  <p>I could use onSubmit on the form button, but prefer to track when the 'Thank You' message is displayed.</p>
  
  <p>It has worked using onLoad and a one pixel .gif, tracking the proper events in Google Analytics, using the code below.</p>
  
  <pre><code>&lt;img src="onepixelimage.gif" onload="_gaq.push(['_trackEvent','Petition','Submitted','Test2']);"&gt;
  </code></pre>
  
  <p>This works fine. But it seems clunky, uploading and hiding a one pixel image on a page feels so 1997.</p>
  
  <p>I feel like I should be able to trigger this event when a script loads, using onLoad.  </p>
  
  <p>But I can't get this code to work:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
     script.onload(function() {
     _gaq.push('_trackEvent', 'Petition', 'Submitted', 'Test2');
     });
  &lt;/script&gt;
  </code></pre>
  
  <p>Does anyone have any suggestions?
  I suspect my Javascript syntax is off, or maybe this just won't work.</p>
  
  <p>Thanks in advance!</p>