WPForms is one of the most popular form plugins to use on a website. The plugin is user friendly and allows you to drag and drop features so that you can create simple but elegant submission forms.
It’s important to track contact form submissions and other activity on your website so that you can make strategic decisions.
When you have the right Google Tag Manager (GTM) triggers in place, you can set up and track conversions and events in Google Analytics, Google Ads, Facebook Business, Yandex. Metrica and other tools. This allows you to gain a bit more accurate picture of the events and conversions – the actions people are performing and the actions you want them to take – that are occurring on your website.
I couldn’t connect WPForms and GTM’s ‘Form Submission’ event, so I believe the two aren’t compatible, which means we need to create our own event.
This is how you do it:
Step 1: Create a Custom Event Trigger and name it as ‘wpFormSubmit’. The event triggers during the wpForm submission.
Step 2: To capture the data, create a new Data Layer Variable and turn on the Form Built-In variables. Select the ‘formId’ variable, it is required to implement the code.
Step 3: Then create the Google Analytics tag Event Listener to send the wpForm data to Google Analytics and set it to fire on the ‘wpFormSubmit’ trigger. Similarly, the data can be sent to Facebook, Yandex, etc as an event.
Now, the code below will send the information to the Data Layer for the Google Tag Manager to pick up.
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'wpFormSubmit',
'formId': 'Simple Contact Form'
});
</script>
The WPForms Confirmations setting has several options. I found the one that worked best was the ‘Message’ one.
Select the ‘Text’ view and copy and paste the JavaScript code above so it runs on a successful submission.
Follow the steps above and you’ll be able to track WPForms contact form submissions easily.