Can I Intercept Lead Flow Exit Intent Form Submissions?


For tracking purposes, I’d love to be able to intercept the exit intent (lead flow) form submission and send some custom ga() calls. Is there any type of “onSubmit” or “onComplete” I can tie into? As a shot in the dark, I tried adding a “submit” event listener to the “form” tag…but obviously that didn’t work as it’s a JS submission and it’s not using that “form” tag. Any help here would be greatly appreciated.


I had a similar issue. I needed to pass a submission event to google when a form was successfully submitted.
Hubspot does have a jquery based onsubmit function.

      portalId: '',
      formId: '',
      onFormSubmit: function($form) {

I didn’t want to include jquery on my site just for the event tracking.

function gaSend() {
    var errVal = document.querySelectorAll('.hs-error-msgs').length;
    if (errVal === 0) { // any invalid fields
      clickTrack('form','submit'); // external clicktrack function for custom ga tracking script
 function formSubmit(id) {
    setTimeout(function () {
        var formId = document.getElementById(id);
        if (formId.length) {
          formId.onsubmit = function () {
              setTimeout(function () {
              }, 0);
     }, 500);
  window.onload = (function () {
    formSubmit('hsForm_9b403ba0-d5ef-4d35-95f3-68487e59e016'); // know form ID

You do need to account for outbound link submissions when writing your ga(send) script.
Hubspot forms reload the page on submission


Hey Matt…I actually do use something similar for the “standard” Marketing Forms on HubSpot…but I’m referring specifically to the “Lead Flow” forms for “exit intent” etc…I don’t think they use the same API. I could be wrong though.

As for tracking the standard forms with the API…it’s easy enough to just do a virtual pageview send ex: ga(‘send’, ‘pageview’, whatever…) – using the onFormSubmit…At least that’s the way I do it…then it appears in as a virtual pageview and can be tracked as a goal in Google Analytics.