Ninja Forms, with over 800,000 active installations, is a widely used plugin for creating contact forms for WordPress websites. The plugin offers aesthetically appealing forms without requiring developer skills and supports various types of payments.
There are two practical ways to track Ninja Forms with Google Analytics 4 (GA4). The first method uses GA4's automatic form tracking feature, which may not always be reliable. The second and more robust method uses Google Tag Manager (GTM) to deploy a custom tag that pushes data into the Data Layer.
To use Ninja Forms, you need to install the plugin on your WordPress site, create a new form, and embed it on your web pages using a shortcode.
For Ninja Forms tracking with GTM, you need to create a Custom HTML Tag & Trigger and a GA4 Ninja Form Submission Event. The Custom HTML Tag & Trigger involves using a code snippet that captures Ninja Forms submissions by using an event listener with jQuery. After testing the Custom HTML tag, you can create a new tag and trigger to send a form submission event to GA4.
If you have multiple Ninja forms, you'll need to refine your trigger using the GTM Data Layer Variable. This variable will enable you to read the value of the form ID, which you can then use as a condition for your trigger.
Finally, it's important to test the setup by submitting a Ninja form and checking the results in the Tag Assistant.
In conclusion, Ninja Forms tracking can be achieved through GA4's built-in features or using GTM, with the latter being the recommended method. Different types of forms often require different solutions, and there's no one-size-fits-all solution.