Before reading this article, if you are unfamiliar with the WordPress forms plugin, Gravity Forms, please see my blog post “What Is Gravity Forms & How to Use It in 2021“. If you’re unfamiliar with web analytics, specifically Google Analytics and Google Tag Manager, please check out “An Introduction to Web Analytics For 2021“.
Alright! Now, let’s get into some fun stuff with Gravity Forms: Event Tracking!
Unfortunately, one thing Gravity Forms doesn’t offer out of the box is the ability to track form submissions in services like Google Analytics or Matomo. For the purpose of this blog post, I’m going to focus on Google Analytics.
In this blog post, I will show you how you can start tracking events by connecting Gravity Forms directly to Google Analytics or via Google Tag Manager. Personally, I have it connected via Google Tag Manager and that’s my recommended approach.
So, let’s begin! Feel free to watch the video or read below.
Getting Started with Gravity Forms Event Tracking
As mentioned, event tracking for Gravity Forms isn’t provided out of the box. According to their product Road Map (which can be seen only by paid users), “Conversion tracking with Google Analytics” is under their “Planned” section; however, there’s no mention of whether or not it will also work with Google Tag Manager.
Luckily, there is a free third-party plugin available called, appropriately enough, “Event Tracking for Gravity Forms“. This plugin is fairly active on GitHub and integrates with Google Analytics, Google Tag Manager, and Matomo.
So, all you need to do to get started is go into your WordPress Admin, then go to Plugins, then “Add New” and type in the name of the plugin. Once you find it, install and activate it.
Setting Up Event Tracking
Once activated, while in your WordPress Admin, go to Forms and then Settings.
Now, click on the new tab: “Event Tracking”.
This is the default method to send events to Google Analytics and it’s the easiest to get going. All you need to do is enter in your Google Analytics UA Tracking ID, which is usually in the form like UA-########-#.
This is the default option as it works with all Gravity Form configurations. With this option, it assumes you already have Google Analytics installed on your website and doesn’t offer you the ability to install the analytics code.
Event Tracking with Google Analytics
This is the second option available and you’ll notice that it will work only with AJAX forms (basically, forms that don’t refresh the entire page when something on the form changes… which is pretty standard nowadays).
Like in the Measurement Protocol, you’ll need your UA Tracking ID. However, this time you can set a Tracker Name (which I’ve always left blank), and also configure if you want the events to be “non-interactive hits” and if you want the plugin to install the Google Analytics code on your website. I would suggest turning off Interactive Hits. Read more about hits from this article from Google Analytics Help.
Event Tracking with Google Tag Manager
As I mentioned in the introduction, connecting Gravity Forms to Google Tag Manager (GTM) is my recommended implementation. Once you select this option, you’ll notice that there is no option to specify your UA Tracking ID or any type of Google Tag Manager ID.
With this option selected, you’re given the ability to track UTM variables. Without going into too much detail, UTM variables are parameters specified from the URL where the form is embedded. For your digital marketing and email marketing campaigns, you definitely want this checked. You can read more about UTM variables on Google Analytics’ Help page, “Collect campaign data with custom URLs“.
As with the Google Analytics option, you can choose if you want this plugin to install Tag Manager. I personally have this option set to “Do not install Tag Manager” as I use the plugin “Header Footer Code Manager” to manage scripts that are installed on WordPress.
After saving this option, you’ll want to head on over to your GTM Workspace and set up the triggers, variables, and tags so that GTM can capture the data sent from a form and passes it along to Google Analytics.
Create a new Trigger and name it something like “Event – GFTrackEvent”. For the Trigger Type, select “Custom Event” and for the Event name enter “GFTrackEvent” and have it fire on “All Custom Events”.
Here we’re going to create five variables to be collected. Go to “User-Defined Variables” and click “New”. Provide the variable name and for the Variable Configuration, you’ll want to select “Data Layer Variable”.
Here is how I have my GTM Variables setup:
The above are the names for each variable and the actual Variable Name is what’s after the dash. So, for example, the variable DL – GFTrackCategory has the variable name GFTrackCategory.
Now, go to “Tags” and click “New”. For the name, I have it set as “GA – GravityForms Event”.
For Tag Configuration, select “Google Analytics: Universal Analytics” and for the Track Type select “Event”.
Next, for Category, Action, Label, and Value, simply select the appropriate variable that you just created.
Select “False” for Non-Interaction Hit and for “Google Analytics Settings” you can either select an existing variable or you can check “Enable overriding settings in this tag” and enter in your UA Tracking ID.
For the “Triggering” section, simply select the event you just created. In this example, you would select the “Event – GFTrackEvent” trigger.
Click “Save” and then finally click “Submit” to publish the changes to your website.
After publishing the changes to your Google Tag Manager, it may take a few minutes for it to propagate to your website. However, you can verify that things are working correctly if you go into “Preview” mode in GTM and fill out a form and verify that your new event fires. If it fires correctly, the data is being sent to Google Analytics where you can create reports, set up goals, and track conversions!
If you have any questions or comments, please post them below!
Thanks for reading,