How to fire events only when a certain condition is met


Badge

Hey I have a form for which I am defining events. I want to track all the users who filled the phone number filled completely. My requirement is “The event should fire only when the user enters 10 digits in the phone number field”
Also how can we track errors that show up when someone doesn’t input desired format of info. Please find the screenshot.

 


2 replies

Badge +1

Looking for similar solution. 

Userlevel 4
Badge +2

Hi Deepika (and keepcreating), great question. As you observed, a change event is fired anytime the user inputs a value into the field and then un-focuses the field (in other words, the cursor highlights something else, or the user “clicks out of” the field). So if they input ‘123’ and then clicked somewhere else, the change event would still fire. 

There is no out of the box feature to automatically collect events only when certain user-input conditions are met, but there are a few potential solutions to consider:

custom heap.track() event

Your devs can implement a custom event that fires only when the form input value is validated. If you have dev resources available, this is the recommended solution.

custom event properties

You can also consider writing a snapshot property that fires on each autocaptured change event, determining whether the form field input is valid (this would be a regex javascript snapshot -- a fairly advanced use case). You can then create an additional event for changes on the input field filtered for when the javascript snapshot validates the user input.

Summary

This can be done, but the two solutions above require some coding (although not much). I recommend consulting your developers on the solutions above.

Reply