I have a form that submits to another domain I do not own and need to track the event in Google Analytics. I'd rather do it without jQuery to avoid a dependency but I'm failing to understand why this code doesn't work:
<form action='example.com/search' onsubmit='trackSubmit()' id='frm'>
    <button type='submit'>Search</button>
</form>
<script type='text/javascript'>
function trackSubmit(e) { 
  var bForm = document.getElementById('frm');
    bForm.addEventListener('submit', function(e){
    e.preventDefault();
    _gaq.push('_trackEvent', 'Foobar', 'Foobar Form Submit');
    setTimeout(function(){
        console.log('tracking foobar');
        bForm.submit();
    }, 1000);
  }, false);
}
</script>
 
     
     
     
    
