
February 7, 2023
How to Track Gravity Forms With Google Tag Manager: Complete Guide
Updated: February 7th, 2023.
Gravity Forms is a customizable WordPress plugin that enables you to add simple or complex forms to your website, blog, or whatever you’re running on WP.
But just like any important interaction, tracking form submissions is necessary to understand visitors’ behavior better. In this blog post, I’ll show you how to track Gravity forms with Google Tag Manager and send Form submission events to Google Analytics 4.
– Hide table of contents –
- #1. Track Gravity Forms with GTM (short version)
- #2. How To Track Gravity Forms with GTM [long version]
- #2.1. Important: Before we continue
- #2.2. Gravity Forms Listener
- #2.3. Create a Gravity Forms listener
- #2.3.1. STEP 1. Let’s check whether there is a JavaScript API
- #2.3.2. STEP 2. Let’s see which JS API methods are available
- #2.3.3. STEP 3. Are the code examples ready-to-use and very simple?
- #2.3.4. STEP 4. Add dataLayer.push event(s)
- #2.3.5. STEP 5. Create a Custom HTML tag and test
- #2.3.6. STEP 6. Success
- #2.4. Create Trigger (and, optionally, a Variable)
- #2.5. Google Analytics 4 Tag
- Final Words
#1. How to track Gravity Forms with Google Tag Manager [short version]
If you’re in a hurry, just follow these quick steps. But if you want to understand how to evaluate different ways of doing this, read the full blog post.
#1.1. Gravity Forms Listener
Create a Custom HTML tag with the following code:
<script type="text/javascript"> jQuery(document).ready(function() { jQuery(document).bind("gform_confirmation_loaded", function(event, formID) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'formSubmission', 'formID': formID }); }); }); </script>
Set the tag to fire on all pages with the embedded Gravity form (e.g., Page Path contains “contact-us”). This JavaScript code will listen to successful form submissions and fire a Data Layer event called formSubmission.
IMPORTANT: This listener supports AJAX-based Gravity Forms. The listener will work properly if the page doesn’t refresh after submission. If a successful submission sends the user to a separate Thank you page, you’ll have to add additional code to the form’s settings. Read the next chapter to find out more.
#1.1.1. What if my Gravity form refreshes the page or redirects a visitor to a ‘thank you’ page?
You’ve probably figured that the Gravity Form Listener given above does not work in these situations. Instead, you’ll need to log in to WordPress, find the form and add an additional code snippet so that the listener identifies a successful form submission.
In WordPress:
- Go to Forms and open the one you wish to track.
- Then go to Settings
- Click Confirmations.
- Usually, the Confirmation type is “Text” and what you’ll need to do is add a small JavaScript code there. It will create a Data Layer event, “formSubmission”, which we’ll use later as a trigger.
The code snippet that you need to add after the Confirmation message is:
<script> window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'formSubmission' }); </script>
Two important things to keep in mind:
- Before pasting the code, switch the text editor to “Text” mode (instead of “Visual”)
- Disable the auto-formatting in that editor (there’s a checkbox at the bottom). Otherwise, it will break the code.
How to test if this is working? Save the Confirmation settings, enable GTM Preview and Debug mode, return to your form (on the website), and submit it. If you see “formSubmission” event in the Preview console, the code is working fine, and you can move on to the next chapter.
One more thing. If you have two or more Gravity forms on the same page and those forms refresh the page, then you need to modify some parts of the window.dataLayer.push code I’ve recently mentioned.
In this case, both forms should have different codes. The adjusted code of the first form could look like this:
<script> window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'formSubmission', 'formID': '1' // you can replace that 1 with anything you want. Just make sure it makes sense to you. }); </script>
As for the 2nd form, its code should contain ‘formID’: ‘2’.
<script> window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'formSubmission', 'formID': '2' // you can replace that 2 with anything you want. Just make sure it makes sense to you. }); </script>
Why did we do that? different form IDs will help you identify (in the data layer) which form was submitted.
By the way, if the form redirects a visitor to another page (a.k.a. “Thank you page”), read this guide on tracking such forms.
#1.2. Custom Trigger and (optional) Variable
In your GTM account, go to Triggers > New > Custom Events.
Also, create a Data Layer variable called formID if you want to pass its value to Google Analytics. This variable is optional, and you can skip it if you wish. Also, you don’t need this variable if your form refreshes the page and you use the solution described in the 1.1.1 chapter of this blog post.
#1.3. Google Analytics 4 Event Tag
Finally, pass the data to Google Analytics by creating a GA4 event tag with the following settings:
Feel free to remove the {{dlv – formID}} variable if you wish. Assign the formSubmission custom event trigger you have created in the previous chapter of this blog post.
That’s it! Don’t forget to test various scenarios:
- Submit the form when all required fields contain some values. Expected result: the GA4 Event tag should fire.
- Try leaving at least one required field empty and try to submit the form. Expected result: the GA4 Event tag should not be fired.
Also, don’t forget to check Google Analytics Real-time Event reports, as all successful form submissions should be visible there.

#2. How To Track Gravity Forms with GTM [Long version]
Believe it or not, you could have solved this puzzle by yourself, even if you don’t know how to code. In this blog post, I’ll explain various details of how a non-developer can write a little piece of code, use it in Google Tag Manager, and precisely track only successful Gravity form submissions.
#2.1. Important: Before we continue
If, for some reason, this blog post fails to help you track Gravity forms with Google Tag Manager, here are a bunch of other form-tracking techniques.
After tracking hundreds (if not thousands) of various forms, I have polished the most common solutions, so you should definitely check the form tracking guide.
#2.2. Gravity Forms Listener
The entire form-tracking process looks like this:
- We implement an auto-event listener which tracks only successful form submissions and pushes those events to the Data Layer.
- Create a Custom Event trigger (which recognizes the Data Layer Event) and a Data Layer Variable (this one’s optional).
- Create a Google Analytics Event tag, and link it to the aforementioned Custom Event Trigger.
You have probably already tried a built-in Google Tag Manager Form Submission trigger, and it failed you with Gravity Forms. Otherwise, you wouldn’t be here, right? Well, you’re not alone because that trigger rarely works.
So what’s the solution? We should get (or maybe create) a Gravity Forms Listener, a JavaScript function that listens only to successful form submissions and fires a Data Layer event. As a result, we could utilize that event as a trigger and fire a Google Analytics Event tag.
Shall we start?
#2.3. Create a Gravity Forms listener
In 2017, I published a blog post on How to write an auto-event listener with zero coding skills. It received very positive feedback from the community. Today, I’ll demonstrate that technique in action with Gravity Forms.
#2.3.1. STEP 1. Let’s check whether there is a JavaScript API
Open Google and enter Gravity Forms Javascript API. It’s crucial that you look for JavaScript API, not regular API. Your search results should look like this:
The 2nd search result looks promising. Let’s click it. We should be one step closer to writing an auto-event listener.

#2.3.2. STEP 2. Let’s see which JS API methods are available
Now you’ll need to check whether the API is well documented and easy to understand, even for those who do not know how to code. Since we want to track ONLY successful form submissions, we should keep looking for some terms which contain “success”, “form submission”, “confirmation”, etc. You get the idea, right?
What we are looking for is some kind of API method that is related to successful submissions. Honestly, it took me a while to find a proper page in Gravity Form’s documentation (because they offer A LOT of stuff).
On the left side of the Gravity Forms API reference, you’ll find a navigation bar. Go to Hooks > Filters > Confirmations > gform_confirmation_loaded. This JavaScript hook (gform_confirmation_loaded) fires when the form’s “Success” page is loaded (which is exactly what we’re looking for!).
Bingo! We’re one step closer to success, but there’s still something we need to verify.
#2.3.3. STEP 3. Are the code examples ready-to-use and very simple?
Even if the API offers valuable methods and the documentation is very well written, one requirement still remains. Is the API Reference really dummy-proof? Will a non-developer be able to use it with ease?
Honestly, it is not common practice to write super simple code examples in API references which could be helpful for non-devs or beginners. Sometimes it’s even next to impossible.
For example, Wistia offers a very well-written Javascript API reference, but examples are not designed for entry-level developers. Thus, you and I won’t be able to write our own custom auto-event listeners.
In Wistia’s case, we’re lucky to have Bounteous because their developers posted this awesome Wistia listener for GTM. But there are still lots of situations where a ready-made tracking solution just simply does not exist.
OK, let’s go back to Gravity Forms. I have navigated to gform_confirmation_loaded JavaScript hook and found this example of code:
This is perfect! Let me explain what’s happening.
This code is ready to use. It states: if gform_confirmation_loaded occurs, initiate a function. Currently, that function is empty, but we can easily embed the dataLayer.push event just by replacing the text //code to be triggered when the confirmation page is loaded with the actual data layer code.
#2.3.4. STEP 4. Add dataLayer.push event(s)
Copy that code from Gravity Forms API documentation and paste it to some plain text or code editor (e.g., Notepad, Notepad++, Sublime, etc.)
<script type="text/javascript"> jQuery(document).bind('gform_confirmation_loaded', function(event, formID){ // code to be triggered when confirmation page is loaded }); </script>
Remove //code to be triggered when confirmation page is loaded
<script type="text/javascript"> jQuery(document).bind('gform_confirmation_loaded', function(event, formID){ }); </script>
Prepare dataLayer.push event code:
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'formSubmission', //you can actually name this even whatever you want 'formID': formID });
Why did I add formId? Well, that’s because the Gravity Form’s JavaScript webhook returns the form’s ID (see function(event, formId) ?). It’s optional, so feel free to remove it.
Now, merge the Gravity Form’s code snippet with window.dataLayer.push. This is what the final result should look like:
<script type="text/javascript"> jQuery(document).ready(function() { jQuery(document).bind("gform_confirmation_loaded", function(event, formID) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': "formSubmission", 'formID': formID }); }); }); </script>
Great! We’re very close to finishing the Gravity Form auto-event listener!
#2.3.5. STEP 5. Create a Custom HTML tag and test
In the Google Tag Manager account, create a new Custom HTML tag. Paste the code you have created in the previous step.
Done! Save the tag and assign the trigger you want, e.g., All Pages (or, preferably, just on those pages where the form is located).
Don’t forget to test the listener with GTM Preview and Debug mode. Load the page with any Gravity Form and complete a test submission. A Data Layer event called formSubmission should appear in the event stream. Click it and check what data was passed to the Data Layer. It should look like this.
#2.3.6. STEP 6. Success
Victory dance! But don’t relax too soon. There’s still something left to do to track Gravity Forms with Google Tag Manager.
#2.4. Create Trigger (and, optionally, a Variable)
Even though there is a formSubmission event in the Preview and Debug console, you cannot use it as a trigger. Why? Because Google Tag Manager, by default, does not recognize what’s happening in the Data Layer.
So what’s the solution? You’ll need to create a Custom Event trigger. Go to your Google Tag Manager account and click Triggers > New. Create a Custom Event trigger with the following conditions:
In the next step, we’ll create a Google Analytics 4 Event tag. If you want to pass a form ID with it, create a Data Layer Variable. It’s helpful if you have more than one Gravity form on a page or a website.
#2.5. Google Analytics 4 Tag
Finally, let’s pass the data to Google Analytics by creating an event tag with the following settings:
As I mentioned previously, feel free to remove the {{dlv – formID}} variable if you wish. Assign form_submission custom event trigger you have created in the previous chapter of this blog post.
That’s it! Don’t forget to test various scenarios with a GTM Preview and Debug mode:
- Submit the form when all required fields contain some values.
- Try leaving at least one required field empty and try to submit the form.
Also, don’t forget to check Google Analytics Real-time Event reports. All successful form submissions should be visible there.
Final Words: How To Track Gravity Forms with Google Tag Manager
I hope that this blog post was useful. Not only did you manage how to track Gravity forms, but also you learned how to write auto-event listeners without coding skills.
In conclusion, here’s the entire tracking workflow:
- First, you must check how your form works after the successful submission. If it refreshes itself (but not the entire page), implement an auto-event listener with a Custom HTML tag. A listener is a function that listens to particular interactions on a page. In this case, it’s a successful Gravity Form submission. You can either use a ready-made listener (if possible), try to write your own (here’s a guide for non-developers), or ask a developer to help you. A listener must push the event of a successful form submission to the Data Layer.
- If the form refreshes the entire page, you need to edit its confirmation message by adding a little code snippet with window.dataLayer.push. After the successful form submission, it creates an event that you can catch with a custom trigger.
- If the form redirects a visitor to a Thank you page, you’ll need to use this tracking method.
- Create a Custom Event Trigger that would recognize the form submission Data Layer event. It’s a necessary ingredient for the Google Analytics 4 Tag to fire. Optionally, you can create a Data Layer Variable to help transfer Form ID to Google Analytics.
- Finally, create a Google Analytics 4 Event tag that fires when a successful form submission occurs on a page.
If this guide did not help you, don’t feel bad because I have a bunch of alternative solutions on how to track forms with Google Tag Manager. Give it a shot.

83 COMMENTS
Thanks for this post, Julius.
Quote:
---
Finally, pass the data to Google Analytics, by creating an event tag with the following settings:
As I have mentioned ...
---
Did you miss inserting the settings or am I misunderstanding something in how to pass the data to Google Analytics?
Thanks for the heads up! Apparently, the first "as I have mentioned" is there by mistake. Updated.
Thanks for reading!
Thanks ... but :-) ... "Feel free to skip..." isn't really a setting? So I'm still confused what the step is to pass the data to Google Analytics?
This is what I see now:
---
Finally, pass the data to Google Analytics, by creating an event tag with the following settings:
Feel free to skip the {{dlv – formID}} variable if you see no value in it. Assign formSubmission custom event trigger you have created in the previous chapter of this blog post.
----
I have described how to create a "formID" variable and "formSubmission" custom trigger in 1.2 chapter of this blog post.
By saying "Feel free to skip" I meant that you can remove "formID" variable from the GA tag (which was created in the 1.1 chapter of this blog post).
I guess that phrase "feel free to skip" sounds a bit confusing. Updated once again.
Did I understood your comment correctly now?
Sorry but no, (at least to me) it still doesn't make sense :-)
When you write "Finally, pass the data to Google Analytics, by creating an event tag with the following settings:" I would expect some concrete instructions follow.
Same confusion as Rasmus: the event tag settings are missing.
We don't see any settings? i'm guessing a screenshot from the event tag in GTM is not loading.
So just to make sure, you don't see this image in the blog post (it's a screenshot of the GA Event tag)?

I have now re-uploaded the image. Let me know if it helped.
Apparently, unlike other screenshots, this image got blocked by Adbock Plus. It still doesn't show in the post with Adblock activated, but it does show in your comment.
Hi Julius,
Thanks for the post, looks great!
However, there is something I am not understanding...
Why do you need to push an event to the datalayer, when there is already an event that you could use as a trigger?
Why can't we use "gform_confirmation_loaded" as a custom event trigger instead of all that code?
That way (in case it works, which I don't know) you just need one trigger and one tag...
I am trying to implement this but somehow the trigger custom event "gform_confirmation_loaded" is not triggering...
Any idea?
Thanks!!
Hey, all GTM Triggers are based on the Data Layer. If you want a particular interaction to trigger a GTM tag, you need to:
1. send it first to the Data Layer (in this case, we push "formSubmission" event).
2. Then we have to turn that Data Layer event into the actual trigger, that's why we created a Custom Event Trigger which starts listening to "formSubmission" DL events.
Just implement that listener code (via Custom HTML Tag) and you'll be fine.
Yep! I just read about it in the Lunametrics book (much recommended!).
It's clear now thanks to you and them, thank you Julius, great blog and great content, keep it like this!
By the way, do you work as a freelancer in case I need some help with my clients? It could make sense to collaborate!
Regards!
Hey Ricardo,
Yes, feel free to contact me if you need any help with clients. I accept various freelancing work projects. Contact me via julius [at] analyticsmania.com
Julius,
I am trying your approach but somehow it doesn't work on my form.
The event "gform_confirmation_loaded" never seems to be fired, even when the form is submitted correctly.
Any idea of what can be happening?
I mean...
When is this event supposed to be triggered?
I have a form, a payment page (out of my domain) and then a confirmation.
I am only trying to submit the form and get to the payment page, and the event is not triggering. Is it supposed to be triggered there of after payment??
Hi Julius - Many thanks for this. You've written it in such a helpful way.
Dare I ask for another step? I'd really like to know how to get some of the data from one of the questions (eg Year of birth) into the dataLayer. eg. if the form ID is 5, the field is a Drop Down with an ID of 10, and the Value for each Choice is a year (eg 1972).
Could you possibly let me know if that is possible, and point me in the right direction how to achieve it? I understand if it's a bit involved and is a separate post in it's own right.
Cheers, Rob
Hey, I'd contact Gravity Form's developers and ask for advice. I've just checked their JavaScript API (https://docs.gravityforms.com/gform_confirmation_loaded/) and cannot see anything about retrieving the value of particular form fields.
But since they are developers, I'm pretty sure they should have some tricks hidden up their sleeves.
Thanks Julius. I'll post here if I get a solution.
Hey Robert, did you ever discover a solution for this?
I do a lot of dynamic variable passing to analytics and the lack of that would be a pain.
Been tackling this all afternoon with no luck.
Hi,
Just a quick question. Will I be able to distinguish between different forms (I added an ID 1 and ID 2) in Google Analytics when checking my goals?
Hi,
The Gravity Form Listener (which I published in this blog post) also pushes formID to the Data Layer. You'll just need to create a Data Layer Variable and use it in the Google Analytics Event Tag. For example, you can insert {{formID}} variable to the "Event Label" field.
Now, back to your question. In standard Google Analytics Goal Reports you won't be able to distinguish which form was filled in. Nevertheless, you can achieve the result by creating a custom GA report, where the main metric is that "Form Submission" goal and one of the Dimension Drilldowns is Event Label (if you pass the {{formID}} variable as an Event Lable).
FYI: I've just updated this blog post and added a new chapter (#1.1.1) explaining how to track Gravity forms which refresh the entire page (because the auto-event listener does not work in those cases).
Now, you should be able to track all Gravity Forms. Cheers!
Thank you for the awesome solution!
If I reload the page with thank you message, this triggers form submission event. How can I avoid that? Also, do you have any good idea for measuring first interaction - an event push when a visitor puts the first value on a form field?
Thank you in advance!
1. Prevent duplicates - read this for inspiration https://www.simoahava.com/gtm-tips/prevent-repeat-transactions/
2. You can track clicks on a form field. Or combine this https://www.simoahava.com/analytics/track-form-engagement-with-google-tag-manager/ with this https://www.simoahava.com/analytics/simple-custom-event-listeners-gtm/ (if you are a beginner, this will be a very hard task, therefore, maybe click tracking will be a good start).
Great, thanks Julius!
All spot on Julius!! another great post and a huge time saver!! thank you
You're always welcome!
I'm new using Tag manager and Data layer, Trying this tutorial no data layer event appears on Preview Mode.
I've only added the Tag Manager code on my wordpress ¿Should I declare the data layer object form submission that appears on the Gravity form listener?
Solved, I didn't scrool on preview mode, also I was misspelling the event name: formSubmission on the custom trigger so any data passed to Analytics.
Pretty useful post, thanks a lot!
I'm glad you found the solution, Fernando.
I thought I'd jump in here with regard to the formID variable. If you have 2 forms on a single page and you're using the trigger for custom event formSubmission, you will receive a submission event for both forms on the page with the same formID. The trigger needs to distinguish the forms, in this case we used added the default form ID to the trigger, but that means you need 2 triggers, not just one for both forms, unless I'm missing something. Thanks for a great post!
Hey, you can use one trigger for both forms. Just in trigger's condition use "Matches Regex" operator. For example:
Form ID Matches Refex (ignore case) form1|form2. That way the trigger will be looking for forms which have ID "form1" or "form2".
Under section 1.1.1, what if the confirmation type is redirect (to a pdf)? I can't use a page view trigger in that case, and don't have the ability to add the formSubmission dlv event text.
Thanks for diving in to this!
Redirecting to a pdf will not work because you cannot add GTM code to the pdf file. Therefore tracking the is impossible.
Maybe you could redirect a visitor to some other page which could be considered as a unique Thank you page?
What about redirecting to a url (that we can track) that redirects to the pdf? Is this a bad idea?
Yes, because you need a temporary page between those redirects which should give enough time to GA to fire an event tag. Not very robust.
Hi Julius, great article. As a technical SEO and developer, this is right up my alley even though learning the ins and outs of GTM has been fun (read challenging).
I have an honest question - and I know this tutorial is meant to be just that, but what's the use case for tracking if a form is successful or not, shouldn't you also track all form submissions, errors and successes.
I hope that question doesn't across wrong, curious what kind of data business people are interested in...such as perhaps, why a form fails, or where users get stuck on a certain field.
Do you have any real life examples, of where form tracking meets GTM has worked for you? Thanks!!!
That's a good question. Tracking all the interactions might create noise in your reports. Feel free to track both (just make sure that you can distinguish them somehow in your tracking tools).
The main reason why I emphasize the tracking of only successful submissions is conversion tracking. When someone lands on your website and submits an important form (subscription, account creation, whatever), you want to track only successful submissions as goals in your Google Analytics, conversions in Adwords, etc. By tracking successful submissions you can measure the success of your marketing efforts.
You can go an extra mile by tracking the "failure rate" of errors in your forms but such technique is pretty rare.
Julius,
This is great! Thanks for taking the time to make such detailed explanation.
For those that had my situation, 2 forms on the same page. A Contact Us Form (that Refreshes the Page) and Subscribe (That doesn't Refresh the Page). Just add the script to the confirmation tab of the Gravity Form that refreshes, as described above, not to both forms.
Example:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'formSubmission',
'formID': 'Contact Us Form' // you can replace that 1 with anything you want. Just make sure it makes sense to you.
});
Now if I could only figure out how to replace the subscribe formID with something meaningful the formTitle I'd be golden. :)
Hey why don't you just rename form ID into something else?
Gravity forms does not provide that option and adding the script above to the email confirmation triggers two form submissions.
I'm not familiar with this situation but I'd be happy to take a closer look. If you want, feel free to contact me via email (julius at analyticsmania.com)
In that email, please include a shared link to a Preview and Debug mode + a screenshot of both Gravity forms in the WP admin.
This has been working brilliantly for ages across a huge range of clients, however we've had two instances lately where one form on a website will trigger two formSubmission tags to fire and thus two events into Analytics.
I've gone through with a fine tooth comb and can't see any variance in settings between the form with the issue and any others on the site.
Do you have any idea why this might be happening? Hoping it's a super silly issue I've not thought of the simple solution for.
Hi guys,
If you have your developer add this to the theme functions.php, you will be able to add form name to the Analytics Tag. So this way you won't be stuck with the ID's in Analytics
Step 1: Add a filter in functions.php (your developer knows)
add_filter( 'gform_form_tag', 'form_tag', 10, 2 );
function form_tag( $form_tag, $form ) {
$form_tag = preg_replace( "|action='|", "name='" . $form['title'] . "' action='", $form_tag );
return $form_tag;
}
Step 2: Make a Data Layer Variable in GTM
dlv - Form Name
Data Layer Variable Name: formName
Step 3: Edit/add Google Analytics Event
Action: {{dlv - Form Name}}
This was super helpful for us. One thing I did to make the label in GA a bit more user friendly was to use a Lookup Table variable that converts the form ID into a friendlier name. If the the ID wasn't defined in the look up table, it falls back to the page .
That might not work in every situation, but for this particular site it means the GA reports are a bit easier to understand without having to reference the Gravity Forms section of WordPress.
Hi,
Thank you for your post.
I have tried the built-in Google Tag Manager Form Submission trigger and it is working when the Gravity form is submitted. The page also reloads after the submission.
is it okay to use this trigger despite your post suggesting other methods?
I also need to push some information in the forms to the data layer, do you have any article regarding the extraction of data from forms and pushing them into the data layer?
Many thanks
This was interesting and I think I understand it more, but it's still not working for me, sadly.
Hey, if you provide more details, maybe I can help.
Thanks for the offer! I wish I understood why it wasn't working so I could tell you more. What I ended up doing to get it working was get a plugin that did a few things...
Turned all the forms into AJAX (some forms like the widgets weren't set up that way).
Assigned Category, Actions and Labels to the forms.
This worked for me but on pages where there are multiple instances of the same form I still can't tell which form they filled out.
Thanks for writing this guide though! I wouldn't have known what to search for when looking for an alternative solution.
So when you submit the form and go to the "Data Layer" tab in the Preview and Debug mode, you don't see the "formID" key with some value? (as I have mentioned it in step #2.3.4.
Before the plugin, no. Nothing was coming up at all.
Send me an email to [email protected] and I'll take a look.
Thanks for this really helpful article. I have used this for a number of clients with great success but am having a similar problem to Sholto, where one form on a website will trigger two formSubmission tags to fire and thus two events into Analytics.
Do you have any idea what could cause this?
Hey, I have not clue what Sholto is :) Anyway, one of the solutions would be to set the GA tag to fire only once per page. Then 2 formSubmission events will not cause problems.
I just implemented this on a site and it did track the form submission when I was in Real Time, but when I look at the Goal Hits in the last 30 minutes, 1 submission is registering 4 times. Submitted it again and now that number was 8. So it looks like for each 1 form submission, 4 are getting registered. Any ideas on how that happens?
So is the tag also firing 8 times? If yes, you could try to set the GA tag to fire only once per page.
Hi Julius,
Thank you for the reply! The tag was actually firing 4 times per 1 submission. I switched from "once per event" to "once per page" and it seems to be working better. Just tested it and 1 submission matched 1 conversion. I will be leaving as is today and checking again tomorrow to make sure the number of actual submissions matches the conversion in Google Analytics. I will update this again if I find any other issues. Thank you again!
Hey, thanks for the info! I use Gravity Forms on Wordpress and have a GA goal set up to fire based on "Category, Action, Label" when it matches with GF form submission. It already fires as a conversion for all my forms. I'm running my GA through the GTM container. So I'm a bit confused...what happens if I set up the same form submission as a tag in GTM? Will it fire twice? Also if I'm setting a goal in GA for my main events, why do I need to set it in GTM at all? And lastly, for some reason, when I imported one of my Goals from GA into Adwords via Analytics, to track those conversions, it won't track those conversions on just one form...all the others work. That began my journey to see if I can configure something in GTM to track those conversions, but now I'm just confused what to use where.
If you also implement the event via GTM, then you'll have double events.
In GTM, you're setting NOT the goal, but the event. In GA, you're setting a goal that is based on an event sent by GTM.
Regarding, Google Ads, it's hard to say something without knowing the context.
Ok, that makes sense now. Right now we have the goal set in GA to fire based on Gravity Form plugin so it records directly from there. But I have the option to set the parameters with GTM of when the event will occur and send that to GA. Thanks for the clarification.
As far as the Adwords, the solution turned out to be simple. When I created a different view for a new set of goals, the data syncing between GA and Ads for that view wasn't toggled on.
Thanks again for such an extensive post and for responding!
If we are redirecting to a confirmation page after a successful submission, there is no way to track the event?
Step 1.1.1. opens with what we can do in such a case, but then provides a solution that requires adding script to the text field which is not available when using the redirect setting...
Any insights?
If the URL of the Thank you page is quite unique, you can just track the regular pageview https://www.analyticsmania.com/thank-you-page-tracking-google-tag-manager/
Just had the same question in your course's Facebook group. Client is reusing the same thank you page for all similar forms. If there is no way to push an event to the the datalayer on submission and redirect then I guess I'm going to lobby to switch to AJAX forms and just add thank you page content(additional links and such) to the text confirmation .
Thank you for your tutorial, it's great work and well explained :)
I am trying to find a way to get an array of every form field and its values in the data layer formSubmission as explained in a different tutorial for Contact Form 7. I'm looking in the Gravity Form JS API methods, but no chance yet... :/
Hello !
I have to add form fields in data layer so that i can send it to my marketing software for marketing my content according to the user behaviour!
Please help me to push gravity forms field into data layer on page load using GTM!
Julius, I've been using your method now for over a year without error, but now all of a sudden I'm seeing 2 events for each form submission.
While monitoring Analytics > Realtime > Events, I see both for one form submission:
formID = Contact Us
formID = 1
One event has the formID specified in the confirmation script: "Contact Us",
and the duplicate is showing the form's actual ID, formID = 1
As a temporary solution, I've deleted the confirmation script and just use the formID = 1 event. But I'd like to go back to how it was working before. Any ideas?
Maybe Gravity forms updated and changed something. Not sure.
You can also set the tag to fire once per page. That can also work.
Thank you for your tutorials, they are all great. I've got all of the tracking setup and working on a variety of forms throughout my sites. But I have some payment / subscription forms. How do I track the submitted "value" (which will be equal to the "Total" gravity field)?
Tbh, this confused me a LOT. Screenshots are since long outdated which means it's incredibly hard to follow... Not sure if I'll finish this tbh.
Hello! Love your website and tutorials. Quick thought on a question above about accessing particular form fields within the listener and pushing to variable - I found some definitions for form object on Gravity Forms API docs here (https://docs.gravityforms.com/form-object/). There must be some way to configure the listener function to access these fields via the data form object, no? They fact that they GF is passing formId variable indicates to me that we should be able to access it, I'm thinking. What do you think?
Hi, the link you shared is for the backend functionality. Not for tracking with Javascript. The listener returns only form id. Other fields are not passed.
Yep, after I post the comment yesterday I realized that's OK. This particular API allows us to access the form object data server-side only. So I guess what could be done is to use a GTM script to callback a script in the form submission hook, and push the response to data-layer variable, if it was my goal to handle form data with GTM. That might be useful to anyone else who read these comments and asked the same thing.
Hi Julius, is it possible to track track Google Ads campaign conversions of Gravity Forms submissions with payment?
For example, client has display and search and ad campaigns. We would like to track Google Ad clicks to site which result in Gravity Form purchase/submission. The revenue from a form needs to populate in Google Analytics.
Any feedback of any kind would be greatly appreciated.
Thx much, Mark
Hi!
Loved the setup you made here!
Everything seems to be working, the events show up on Real Time when the form is submitted but When I check Behavior -> Events, nothing comes up?
Where can I see all the submissions on GA?
Thank you!
Hi
Behavior > Events are not realtime. You must wait for several hours (up to 24 hours)
Hi Julius! Thanks for the quick reply!
Oh, cool! Had no idea, this is my first try at both GA and GTM.
Will check that link as well.
Cheers!
Hey Julius,
This works but I get an error in the console saying jQuery is not defined. Is there a way of writing the script without using jQuery(document).ready(function() ?
Fixed it. Changed the trigger to DOM Ready.
This is great! One thing I'm wondering is how would I track when someone x or closes out of a gravity form? I tried building a trigger based on the click element but that didn't work
I would still try to track the click on that button. If it does not work for you, then the problem is somewhere in the trigger condition.
Hi Julius,
Another great post - thank you!
One question though. I've tried to setup a goal in Google Analytics and for whatever reason, I can't seem to get it to work. I can see the events in the realtime report, so I know the data is there, but there's nothing registering as a goal :(
Hi Julius, thanks for making this awesome blog. it's really useful. but on my website. I added the payment option to the form. when someone submitted the form user will redirect to the PayPal payment option then the user will redirect to a specific thank you page. so in this case should I use the confirmation code?
My events will only fire and show as a conversion inside the tag assistant manager. But if I perform a form submission test just using the regular browser it doesn't. Any ideas????