Update time: January 12, 2025
This article introduces how to track forms in Gravity Forms.
When the form is successfully submitted, gform_confirmation_loaded will be triggered, which can be used to send events, such as:
<script> jQuery(document).ready( function() { jQuery(document).bind('gform_confirmation_loaded', function(event, formId){ window.dataLayer.push({ 'event' : 'gravityFormSubmission', 'gfformID' : formId }); }); }) </script>
Now we need to track the form submission in https://www.gravityforms.com/open-support-ticket/general/
Next, let’s see how to implement form tracking:
Step 1 : Custom HTML to inject javascript
In GTM , click「Tags」——「New」——「Choose a tags type to begin setup…」——「Custom HTML」,Name it “HTML – Gravity Forms Listener”, and make the following settings:
In fact, it is the jQuery Method. Read more: GA4 Event Tracking Series ⑧ —— Custom Events (jQuery Method)
Step 2 : Set Up the Variables
From the code, we can know that there are data layer variables gfformID in the data layer, which need to be obtained using data layer variables in GTM.
In GTM, click「 Variables」——「New」——「Choose a variable type to begin setup…」——「Data Layer Variable」, name it “dlv-formID”, and then set as follows:、
Step 3 : Set Up the Trigger
In GTM , click「Triggers」——「New」——「Choose a trigger type to begin setup…」——「Custom Event」,Name it “Custom Event- Gravity Forms Submit Form”, and make the following settings:
From the code, we can know that the event is gravityFormSubmission, so the event name is set to gravityFormSubmission
Step 4 : Set Up the Tags
In GTM , click「Tags」——「New」——「Choose a tags type to begin setup…」——「Google Analytics: GA4 Event」,Name it “GA4-Event-Gravity Forms Submit Form”, and make the following settings:
The event name is submit_form_gravity_forms
Step 5 : Preview and Publish
Next is preview debugging.
Tags is triggered and can be published.
Read More:
Step 6 : Custom Definitions
The next step is to register event parameters form_id, if you want to use it in GA4, you need to register it in the Custom definitions of GA4.
In GA4,click「Admin」——「Custom definitions」——「Create custom dimension」, then do the following configuration:
Step 7 : Verify Data in Reports
Generally, after 24 hours, we can see the data in GA4, such as: