{"id":4603,"date":"2020-08-19T09:00:00","date_gmt":"2020-08-19T06:00:00","guid":{"rendered":"https:\/\/trackingchef.com\/?p=4603"},"modified":"2024-10-28T18:59:50","modified_gmt":"2024-10-28T15:59:50","slug":"form-abandonment-tracking","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/google-analytics\/form-abandonment-tracking\/","title":{"rendered":"Form abandonment tracking with (and w\/o) Google Tag Manager"},"content":{"rendered":"\n
A common requirement in measurement plans set by Marketing or Product teams is the ability to track form abandonment. With many of the teams mentioned above stressing over bringing in more and more leads, the ability to analyze and address where and why users drop off is important.<\/p>\n\n\n\n
While there some tools that can measure a form’s conversion rate (e.g. Hubspot’s built feature<\/a>) and even analyze specific fields (e.g. Hotjar Form Analysis tool<\/a>), measuring this in Google Analytics can come in handy for in-depth analysis.<\/p>\n\n\n\n The output of measurement described below is this table of events in Google Analytics that can be used to analyze the drop-off points of users.<\/p>\n\n\n\n Another classic use case of this data is creating Remarketing audience from these users that had expressed a clear interest in your product or service and only need that extra nudge. These can also serve as a great seed for and Lookalike audiences too.<\/p>\n\n\n\n Since this triggers a generic event, it can be used to create these audiences in any ad platform aside from Google Analytics\/Ads, for example on Facebook Ads or Taboola.<\/p>\n\n\n\n The simplest way I usually go about this is with Google Tag Manager (GTM). If you’re using GTM4WP, this is already baked in as an event (will appear in the Data Layer as gtm4wp.formElementEnter<\/em> & gtm4wp.formElementLeave<\/em>).<\/p>\n\n\n\n The method described below is based off of the Generic Event Tracking<\/a> mechanism I’ve previously posted about. Using this generic tracking, adding additional event such as the form abandonment is a breeze.<\/p>\n\n\n\n The first step to handling form abandonment is being able to identify to which point has a user gotten within a specific form. To achieve this we will use a simple jQuery script. <\/p>\n\n\n\n Important: The purpose of this script is to capture a change in the value of a form field, and send the label of that field to GTM.<\/p>\n\n\n\n We will add this script as a Custom HTML tag in GTM. You can set the tag to trigger on any page or only on the pages where there are forms (e.g. only the Contact Us page).<\/p>\n\n\n\n The output of this script will be an event sent to Google Analytics (using the Generic Event tag in GTM). The event’s name is ‘form interaction’ and the event’s parameter ‘form_field’ will record the field interacted with.<\/p>\n\n\n\n In the example above, the field will be identified by its placeholder text. You can extract the field’s label attribute by replacing the placeholder<\/em> value with label<\/em>.<\/p>\n\n\n\n In Elementor forms, this value is also referenced as name<\/em> or id<\/em>. You can also grab the field’s label or the form’s name with a minor alteration:<\/p>\n\n\n\n You can also check out my guide on Bulletproof Elementor form tracking with GTM<\/a>.<\/p>\n\n\n\n In CF7 forms, this value is also referenced as id<\/em>. You can also grab the field’s label or the form’s ID with a minor alteration:<\/p>\n\n\n\n You can also check out my guide on Bulletproof Contact Form 7 tracking with GTM<\/a>.<\/p>\n\n\n\nForm abandonment tracking with Google Tag Manager<\/h2>\n\n\n\n
Adding the Custom HTML tag<\/h3>\n\n\n\n
\n
<\/strong>This assumes you already have jQuery active on your site (WordPress sites ship with it by default). If you don’t use jQuery, see the Vanilla JS solution below.<\/p>\n<\/blockquote>\n\n\n\n<script>\njQuery(\"form input, form select, form textarea\").change(function() {\n dataLayer.push({\n 'event': 'form interaction',\n 'form_field': jQuery(this).attr('placeholder')\n })\n});\n<\/script><\/code><\/pre>\n\n\n\n
jQuery(this).attr('label')<\/code><\/pre>\n\n\n\n
Elementor forms <\/h4>\n\n\n\n
'form_field_label': jQuery(this).parents('div').children('label').text(),\n'form_field_id': jQuery(this).parents('form').attr('name')<\/code><\/pre>\n\n\n\n
Contact Form 7 forms <\/h4>\n\n\n\n
'form_field_label': jQuery(this).parents('label').text(),\n'form_field_id': jQuery(this).parents('.wpcf7').attr('id')<\/code><\/pre>\n\n\n\n
Gravity forms<\/h4>\n\n\n\n