Home » Javascript » Call Javascript Function On Form Submit

Call Javascript Function On Form Submit

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have an email signup form that I need to call a javascript function to track conversions back to google AdWords. I’m having trouble adding the call into the form without breaking it.

Here is the javascript function that needs to be called:

<script>
function gtag_report_conversion(url) {
  var callback = function () {
    if (typeof(url) != 'undefined') {
      window.location = url;
    }
  };
  gtag('event', 'conversion', {
      'send_to': 'AW-XXXXXXX/XXXXXXXXX_XXXID',
      'event_callback': callback
  });
  return false;
}
</script>
Answers: