In this article, let's get our hands dirty and implement form event tracking and monitoring.
HTML Form
Let's start with a simple HTML form.
Above is a simple registration form with name, email and submit button.
Identify what events we want to track
From marketing perspective, a registration form is a conversion funnel, I'd like to track how many users visit the form, how many of them interact with the form, and how many of them successfully submit the form, so basically I want to track the following events:
Web visit
Focus on the form / interact with the form
Click submit button
Submit form successfully
Implement event tracking
Now that we have a basic event trakcing plan, let's implement it.
Web visit
session id is a unique identifier for a user's session, with this we can track how many users visit the form and how many users interact with the form.
Focus on the form / interact with the form
Next, we want to track when a user focuses on the form or interacts with the form, we can use focus and input event to track this.
Click submit button and Submit form successfully
Click button is not equals to submit form successfully, so let's track the click event first, and then if the form is valid, then we can track the submit event.