Logging a Munchkin hit when someone *starts* filling out a form

Some small signals from end users — stressing some[1] — can be disproportionately meaningful. One such signal: that they started to fill out a form, so you can compare/intersect with people who eventually submitted the form.

The delta between the 2 is, of course, people who became distracted/discouraged/disengaged (or, in the interest of completeness, who couldn’t submit the form due to forces outside their control).

Of course, we need to define our terms.

Does “started” mean “focused – either by clicking, tapping, or tabbing – a visible form field”? (That’s what it means to me by default, FYI.)

Or does “started” mean “changed a value” in a visible form field? This definition might seem more precise at first, but the problems are (a) there’s no need for someone to change a value in order to submit a form – remember Pre-Fill – and (b) there’s no single browser event that can account for all types of net changes, making the accompanying JavaScript very complex.

There are other directions to take with “started,” and all manner of JS hooks to build (veering quickly into way-too-much-to-be-useful and breaking-other-stuff-accidentally). Today I’m going to stick with the simplest definition: Did someone move focus to the form?

Here’s how that’s done:

  var formEl = form.getFormElem()[0],
      formId = form.getId();
  formEl.addEventListener("focus", logFormStart, true);

  function logFormStart(e){
     formEl.removeEventListener("focus", logFormStart, true);
       "url" : document.location.pathname + "#!/inPage/startedForm/" + formId

Then you’ll see a hit — one supplementary hit per pageview, naturally — in the Activity Log:


/startedForm is also logged if they submit the form without touching any fields, because the act of clicking Submit is a form of focus. (This is A Good Thing.)

Note the hit will stay in the Anonymous Activity Log if the person never converts, but moves to the standard (Known Lead) ActLog after their session is associated. As with all Visit Web Page activities there’s ongoing backfill.

I’ll leave it to you to come up with meaningful Smart Lists using this info. :)

Because Munchkin clickLink blocks the browser UI thread. And if you don’t know what that is: trust me, it’s A Very Bad Thing.

I’d go far as to say all custom Munchkin code that uses clickLink for in-page events (non-unloading events) instead of visitWebPage is lowkey broken — admittedly including some of my own older code. Someday I’ll get to a blog post specifically about this, but for now: trust me.


[1] I feel strongly that logging every minor-to-meaningless page interaction is wrong. That not only creates chaff on the server side, it’s also disrespectful to users with low-quality connections. I’m stuck on slow DSL, people!