Would you like to track your form submissions using Google Analytics 4 and Google Tag Manager? Effective July 1, 2023, standard Universal Analytics properties will be going away and will stop processing new hits and will be replaced with Google Analytics 4, their next-generation measurement solution.
To read more on this subject, please check out Gooogle’s support thread on this subject.
Setting up Google Analytics 4
To begin, you should follow Google’s documentation on how to set up and use Google Analytics 4.
If you have already been using Universal Analytics and want to set up GA4, please check out their documentation on the GA4 Setup Assistant.
If you haven’t used Universal Analytics previously and need to set up your GA4 analytics, please review their walk-through setup documentation.
For the purpose of this tutorial, we’ve used the GA4 Setup Assistant to automatically create our Measurement ID and Data Stream.
Using Google Tag Manager
In the next few steps, we’re going to create a trigger, create a tracking event and connect this through Google Tag Manager to Google Analytics 4.
Creating the Trigger
For the purpose of this documentation, we’re not going to go into full detail on how to create a trigger, for that you should read Google’s article on the subject found in this documentation.
However, we will show you what we used for this tutorial.
What we’re doing here is telling the trigger that whenever they see the CSS class name .wpforms-confirmation-container-full appear on the page (whether this is through page reloading or through the AJAX display) to activate this trigger. We only need the 1% visibility and we’ve enabled the Observe DOM changes so that just in case there is AJAX-enabled on the form, we would still fire this trigger when the confirmation message is displayed.
Adding the tag
Once you’ve created your trigger, you can now add your tag. Again, there are many tutorials out there for this so we won’t walk through every step but we will share with you the settings we used for ours.
Our tag, we’ve set up the Google Analytics: GA4 Event using the Configuration Tag set to None- Manually set ID. This is where you will copy and paste your GA4 MEASUREMENT ID.
The MEASUREMENT ID number begins with a G and replaces the UA number you used previously on Google Universal Analytics. If you need help locating the MEASUREMENT ID number, please check out this documentation.
Next, just give the Event a name that makes sense to you and if you’d like you can add extra Event Parameters to pass through when the tag is fired.
Once you’ve completed the top section of the tag, you can click on Triggers and select the trigger you created in the previous step.
Google has recommended event names that are already pre-programmed to accept certain parameters. For a complete list of Gooogle Event recommendations, you can check out this article.
Installing Google Tag Manager
To complete the insertion of the tracking code we created in Google Tag Manager, we just need to follow the steps to install GTM to our site so that it can begin recording our events.
To find the scripts you need to add, from inside the Tag Manager Overview page, click on Admin, then click the Install Google Tag Manager.
You will see the scripts you need to add and where they needed to be added to. There are several different ways of doing this, you could create a child theme or use a plugin like Insert Headers and Footers to add your script.
In our tutorial, we created a child theme following this tutorial from WPBeginner, and added the necessary script to the
head section of our WordPress site.
Once all the pieces are in place, your Events reporting will begin capturing all form submissions.
Q: Will this record all WPForms submissions
A: If you are displaying the confirmation message on form submit, yes. This tutorial will record all form submissions.
Q: How do I track if I have a Thank You page?
A: If you are using the WPForms Redirect on your Confirmations tab, you can set your trigger up to use Page View instead of the CSS Selector. And there you can enter the URL for your Thank You page.