{"id":4787,"date":"2020-11-25T13:32:32","date_gmt":"2020-11-25T10:32:32","guid":{"rendered":"https:\/\/trackingchef.com\/?p=4787"},"modified":"2024-12-09T12:20:53","modified_gmt":"2024-12-09T09:20:53","slug":"bulletproof-gravity-forms-tracking-with-gtm","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/google-tag-manager\/bulletproof-gravity-forms-tracking-with-gtm\/","title":{"rendered":"Bulletproof Gravity Forms tracking with GTM"},"content":{"rendered":"\n

Gravity Forms<\/a> (GF) is the most popular paid contact form plugin for WordPress, second only to the free Contact Form 7<\/a> plugin (aka CF7). <\/p>\n\n\n\n

While CF7 comes stripped of any design, GF is fully customizable and comes with simple integrations for Zapier and Hubspot already baked in.<\/p>\n\n\n\n

In this post, I’ll discuss several methods to capture form submissions on GF using GTM.<\/p>\n\n\n\n

The best course of action is to redirect the users to a Thank You page after a successful form submission. This interaction is simple to capture across all ad and analytics platforms.<\/p>\n\n\n\n

If you\u2019re using a GF form without a Thank You page (as most users do), you can use Google Tag Manager (GTM) to track form submissions in several ways.<\/p>\n\n\n\n

Form Submission Trigger<\/h2>\n\n\n\n

This is the standard trigger for tracking form submissions in GTM. You can set it up with the Form Submission trigger. While this is simple to set up, it isn’t always a solid solution as it might miss submissions (if the tag didn’t run in time) or send false positives on failed submissions.<\/p>\n\n\n\n

\"\"
Form Submission Trigger in GTM<\/figcaption><\/figure>\n\n\n\n

Element Visibility Trigger<\/h2>\n\n\n\n

This trigger is more stable than the Form Submission. The basic idea behind this trigger is identifying when a user has viewed a certain element of the page. In this case, we ask GTM to identify users that have seen the Thank Message after a successful submission. <\/p>\n\n\n\n

\n

Pro tip:<\/strong>
This trigger works regardless of the text of the Thank You Message<\/p>\n<\/blockquote>\n\n\n\n

To set up this trigger, simply navigate to the Triggers page in GTM a click ‘New’. Select Trigger Type ‘Element Visibility’ and set the Selection Method to ‘CSS Selector’. Paste in the field ‘.gform_confirmation_wrapper<\/span>‘.<\/p>\n\n\n\n

Finally, check the ‘Observe DOM changes’ box or the trigger won’t be able to identify the new page element.<\/p>\n\n\n

\n
\"image-3566929\"
Element Visibility Trigger in Google Tag Manager<\/figcaption><\/figure><\/div>\n\n\n
\n

Pro tip:<\/strong>
You can use a more restrictive CSS Selector to limit the trigger to specific forms, for example by adding the form’s ID to the CSS Selector<\/p>\n<\/blockquote>\n\n\n\n

jQuery Event<\/h2>\n\n\n\n

This method uses a different approach. It adds a jQuery event listener that observes form submissions.<\/p>\n\n\n\n

In layman’s terms, every time a Gravity form is successfully submitted, an “invisible” flag is raised in the page’s HTML code. This event listener will identify that this flag has been raised, and in turn, will trigger your code.<\/p>\n\n\n\n

\n

Pro tip:<\/strong>
This method can be used to track form submissions even without GTM, by triggering the relevant conversion pixel (e.g. Facebook Lead)<\/p>\n<\/blockquote>\n\n\n\n

I like using this event listener to trigger a Data Layer push that triggers my Generic Event<\/a>.<\/p>\n\n\n\n

To use this event listener, create a new Custom HTML tag in GTM and paste in the code below. This tag should be triggered on all pages.<\/p>\n\n\n\n

<script type=\"text\/javascript\">\njQuery(document).ready(function() {\n    jQuery(document).on('gform_confirmation_loaded', function(event, formId) {\n        dataLayer.push({\n            'event': 'form_submission',\n            'form_id': formId,\n        });\n    });\n})\n<\/script><\/code><\/pre>\n\n\n\n

<\/p>\n\n\n\n

Using the Trigger<\/h2>\n\n\n\n

Now that we have a trigger ready, we can use it to fire any tag in GTM.<\/p>\n\n\n\n

For example, you can add this trigger to a Google Analytics event to track form submissions.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

This trigger can now be used to trigger conversion pixels, e.g Facebook or LinkedIn Leads.<\/p>\n\n\n\n

\"\"<\/figure>\n","protected":false},"excerpt":{"rendered":"

In this post I’ll discuss several methods to capture form submissions on Gravity Forms using GTM.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[200],"class_list":["post-4787","post","type-post","status-publish","format-standard","hentry","category-google-tag-manager","tag-forms"],"_links":{"self":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/comments?post=4787"}],"version-history":[{"count":4,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4787\/revisions"}],"predecessor-version":[{"id":6117,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4787\/revisions\/6117"}],"wp:attachment":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media?parent=4787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/categories?post=4787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/tags?post=4787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}