Gravity Form Tracking with Google Tag Manager

Objective: Record all gravity form Interactions

Process:

There is no good way of linking Gravity Forms and GTM that is documented by either party.

I found a method devised by another power user that uses form submissions and started to follow that.

However, form tracking in the way he put it together does not work for us.

I suspect that is because multipage gravity forms don’t have a submission until at the very end.

So, I devised a way that piggybacks on the tag generated when a Gravity Form(GF) is fired.

This tag is generated by placing a custom javascript event.

You can copy the contents below and it should work for you if you use jQuery[help link]

————————————————————————————————————————–

if(jQuery(‘.gform_confirmation_message’).is(“:visible”))/* page load */ { var formId=jQuery(‘.gform_confirmation_message’).attr(‘id’).replace(‘gform_confirmation_message_’,”); dataLayer.push({‘event’:’gform.submit.success’,’formId’:formId}); } jQuery(document).on(‘submit’,’form[id*=”gform_”]’,function(){/* for Ajax Load */ clearInterval(window.gsetInt); var formId=jQuery(this).attr(‘id’).replace(‘gform_’,”); jQuery(this).find(‘.gfield’).removeClass(‘gfield gfield_error ‘) window.gsetInt=setInterval(function(){ if(jQuery(‘.gform_confirmation_message_’+formId+’.gforms_confirmation_message,.gform_confirmation_message_’+formId+’.gform_confirmation_message’).is(“:visible”)) { clearInterval(window.gsetInt); dataLayer.push({‘event’:’gform.submit.success’,’formId’:formId}); } if(jQuery(‘#gform_fields_’+formId+’ .gfield_error’).is(“:visible”)) { clearInterval(window.gsetInt); dataLayer.push({‘event’:’gform.submit.error’,’formId’:formId}); } },200); });

————————————————————————————————————————–

Once you create the event, turn on the preview mode in GTM and see if the GFTrackEvent is firing.

This event works and has the following content:

  1. That tag(“Gravity from custom tracking”) fires and creates an event called “GFTrackEvent”

gf_1

2. I created a trigger,”Find GFTrackEvent”, that fires after the above event fires

gf_2

3. I created dataLayer variables to capture the label from “GFTrackEvent”. If needed,

you can also capture the action but we don’t need it right now.

GFTrackLabel

gf_3

4. I created another tag called  “Event Tracking Tag For Gravity Form” which stores the above dataLayer values

gf_4
This tag gets fired when either “GFTrackEvent” occurs OR when we get to the lead thank you page.

5. The picture below shows them as events being recorded in Google Analytics.

gf_5

Result: The tracking of submission works and also includes the pages that were being paginated to.

Usage: We can use this pagination and lead capture in the dashboard stating now

Improvements Possible: If we want to track the exact options that a user chose on each of the

pages( apart from personal information which Google does not allow), then will have to pick up

information from click elements and somehow fire that as events.

Please let me know if you have any questions.

2 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.