Google Analytics Event Tracking
In this tutorial, We will see how we can track fluent forms events with Google Analytics. Fluent Forms fire jQuery Events in different form states so it will be very easy to track events with google analytics.
In this documentation, We will use google analytics universal gtag. So make sure you are using gtag.js to your site.
Option 1: Track per form basis
Add the following code in that form’s JS code
You can change the event_category or event_label value based on your needs.
At first, It will send an event labeled as “View Form” when the form is loaded on your page. When a user submits a form, it will send another event labeled “Form Submitted”
Option 2: Track Events For All Forms
To track all your form events in Google Analytics you can use the following js code (Please note that you have to add this code universally to your site)
How to add this code via theme’s functions.php file
If you don’t use any snippet plugin or are unable to add this code in your JS file then you can use the following code in your theme’s functions.php file or your custom plugin’s PHP file.