title: Adding Google Analytics event to form submit
body: <p>I'm looking to add a Google Analytics event to a form that I can not access the inline html, so I can not add it as a <code>onClick=""</code> event straight to the html. </p>
  
  <p>So my solution has been so far: </p>
  
  <pre><code>    $(function() {
    $(".form_submit input").on("click", function() {
      dataLayer.push({
        "event": "Kontakt",
        "eventCategory": "Submit",
        "eventAction": "Kirjuta meile",
        "eventLabel": "Kirjuta meile"
      });
    });
  });
  </code></pre>
  
  <p>Althought this does not seem to work as clicking the submit button possibly stops all functions and refreshes the page. </p>
  
  <p>How can I run the function before submit and then submit the form after? I've been suggested using <code>preventDefault();</code> and the after calling the submit again with <code>$('form').one('submit', ...</code> but have been unable to implement this due to lack of skill.</p>
  
  <p>View site: <a href="http://avrame.com/en" rel="nofollow noreferrer">http://avrame.com/en</a> (the form is at the bottom of the page)</p>
  
  <p>Any suggestions appreciated.</p>