HTML Forms Tracking

It is quite easy to track HTML forms. All you have to do is to create events for every single form. You can navigate through the forms in your source code & add the following code at the submission button code,

ga(‘send’, ‘event’, [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

As a result, it will start reporting an event every single time when a user clicks the submission button.


Nevertheless, what we really want to perform is to track down the completion of every single individual field, not only when the complete form is submitted.


To get this done, we need to place a custom code into the form source code. Which can be find in the Luna Metrics blogs, from there you will get a perfect solution. It is quite easy to implement & you only need to replace few lines, such as the name of the form you have used.


When you place this code on your website, it will fire an event every single time a user fills in a form field or skips it. Which of these events allows you to track down the completion & abandonment of the forms.


AJAX Forms Tracking

AJAX is stand for Asynchronous JavaScript & XML, which is a way for web applications, i.e. forms, to send & receive data from the server, without reloading the complete page. Like, you use AJAX forms so that if a visitor fails to fill out all the required fields, the remaining ones will be marked in red with a message & without deleting the other information they filled in.

Major problem with AJAX forms is the one by creating content on the same specific page, which makes tracking much harder. The page information is rewritten every single time when the event happens &deleting the data layer.


So How Do We Track AJAX Events?

As for this we are going to need Google Tag Manager (GTM)& for illustration purposes, we are also going to use Gravity Forms, which is a plugin for WordPress. Do not setup the exact? Don not worry, this case will work same like working with minor modifications as for the other types of AJAX forms & other types of forms that also use single page.

irst step, you have to ensure that AJAX pages populate the data layer with the variables, which allows you to put triggers on your tags. In addition, the easiest way to perform this is to open the configuration tab of the plugin in admin panel of WordPress. Where you can setup the plugin to send variables to data layers or even directly to Google Analytics.