title: Call a function with the submit button in HTML
body: <p>I need a Google AdWords conversion script to work whenever someone submits a form for a free quote. Google has provided the script which I'm put into a Snippet with WordPress and activated it for the site. </p>
  
  <p>I now need to call that function when the submit button is pressed, but I can't remember the correct syntax and Google searches so far have led me down long paths of .php file creations that isn't answering what feels like a simple solution would solve.</p>
  
  <p>Currently I have added the function in line with the existing code for the submit, but I'm not convinced this is correct. The below code is on the contact form that the page uses.</p>
  
  <pre><code>[submit id:submit class:btn class:btn-primary gtag_report_conversion() "Send"]
  </code></pre>
  
  <p>Below is the code I put into the Snippet minus the full "send to" AW address:</p>
  
  <pre><code>&lt;script&gt;
  function gtag_report_conversion(url) {
    var callback = function () {
      if (typeof(url) != 'undefined') {
        window.location = url;
      }
    };
    gtag('event', 'conversion', {
        'send_to': 'AW-.....',
        'event_callback': callback
    });
    return false;
  }
  &lt;/script&gt;
  </code></pre>