This article builds on the work of Julius Fedorovicius at Analytics Mania to track Forminator's AJAX form submissions using Google Tag Manager.
Forminator is a powerful freemium form builder plugin for WordPress with more than 400,000 active installations. It's also what I use here on technicallyproduct.co.uk. So how do you track Forminator form submissions as events in Google Analytics 4 (GA4) using Google Tag Manager?
Forminator's default behaviour is to use AJAX to send the form without reloading the page, and then display an inline message following successful form submission. As a result, the out-of-the-box 'Form Submission' trigger type in Google Tag Manager doesn't work with Forminator.
One option would be to change Forminator's settings and 'Redirect user to a URL' after a successful submission (this can be set under Forms > EDIT > Behaviour).
If you did this, you could then create a trigger in Google Tag Manager that fired on the 'success' page.
But what if you want to keep Forminator's default settings and still track form submissions? You're in luck - the brilliant Julius Fedorovicius at Analytics Mania has written a comprehensive guide to tracking AJAX form submissions using Google Tag Manager. This in turn makes use of an AJAX listener shared by Bounteous.
I would recommend following Julius' guide while making just a couple of small changes specific to Forminator - one to the Data Layer Variable Name, and one to the trigger.
Here's what the data layer values for the ajaxComplete event look like in the Google Tag Manager preview and debug console following a successful Forminator form submission:
When I first wrote this post, I suggested using the Data Layer Variable Name attributes.response.success. However it occurred to me the following day that both this key and the value (true) were rather generic.
This raised the possibility that something that uses AJAX other than Forminator might add exactly the same key-value to the data layer. And if that were to happen, it could trigger false positive form completions.
Perhaps I'm being overly cautious, but I've changed my own setup to use the following Data Layer Variable Name: attributes.response.data.behav
This has a value of behaviour-thankyou on a successful form submission. Note the British English spelling of 'behaviour'! And if you Google this phrase (with quotes), the only relevant results relate to Forminator so I'm fairly confident that we will be able to avoid any false positives.
Your trigger in Google Tag Manager will also need to be changed to take into account the value you are capturing. My trigger looks like this:
Since I published this article, a couple of commenters have asked about distinguishing between multiple Forminator forms. So I've written a separate guide to this: Differentiating between Forminator forms in GA4 using Google Tag Manager (GTM)
Hey James,
thanks for your input. This looks quite good, however different forms can't be distinguished this way, can they? There is no FormID or similar passed.
Many greetings,
Timo
Hi Timo! There's no FormID, but the ajaxComplete event does include the response message. So if you give your forms different response messages, you should be able to distinguish between them using that.
Hi! Could you elaborate on this? If I was to change the displayed response message to "A team member will contact you via email shortly" what would I change the DLV to? Thanks so much for this great article though!
Hi Genevieve - for your benefit, I've just written a dedicated guide to distinguishing between different Forminator forms. I hope you find it useful! It's here: https://www.technicallyproduct.co.uk/analytics/multiple-forminator-forms-ga4-google-tag-manager-gtm/
Thanks for this. I had initially tried Julius Fedorovicius at Analytics Mania's way and it hadn't worked and now your small tweak to the dataLayer variable actually made my Tag fire. I appreciate it
Hi, I followed the process and the tag is fired but the firing status is failed (and GA don't show the event). Do you have any idea about that error?
Hey James,
thanks a lot for this great article!
What do you think about their solution - https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#form-data-not-sent-to-gtm?
Hi James,
Thanks for sharing this! I've tried to track Forminator submissions multiple ways and the AJAX listener works, but for some reason it keeps triggering twice, with nothing to differentiate between the two ajaxComplete events. In my GA4 settings, I've selected "Ignore duplicate instances of on-page configuration" but this isn't stopping 2 form submissions being recorded. Any suggestions?
Thanks!