dataLayer.push / Google Enhanced Conversions

By: Patrick DeLuca | Asked: 02/02/2023
ForumsCategory: Code HelpdataLayer.push / Google Enhanced Conversions
Patrick DeLuca asked 1 year ago

I cannot believe I can’t find any answers anywhere. Hopefully someone can shed some light into the way Formidable Forms handles the dataLayer.

We have a high volume lead generation site. The bottom of the funnel is a completion of an application. As it does, Google Ads has been harassing me to setup enhanced conversions. A decently easy task, I’ve struggled for months to no avail. When a lead fills out a form and clicks that final submit button, it should push their first name, last name, email address, and phone number to the dataLayer using a code snippet installed in the <head>. Google Tag Manager then grabs the variables, hashes the data, and sends it to Google Ads (if the source was paid search). Problem is, I just can’t get it to work. I tried using the field variables in the form, nothing. I then caught a Formidable field map creep into one of the dataLayer calls ([130]), so I tried to use those parameters, still nothing. 

I’m able to capture the event, the form name, even the fields, but no data within them. 

Not using MonsterInsights, SiteKit, or any sort of plugin integration for GTM - we’ve got code in the head and body and it is firing as I can see the dataLayer and can see Formidable data within it - just not the data we want. 

Any help would be appreciated. Latest version of WP, hosted on WP Engine, using Formidable Pro. 

It’s a two page form, so what is below is from one form fill, though it looks like two. Here is the output I’m getting from the dataLayer: 


{ event: "form_start", gtm: {uniqueEventId: 0, start: 1675379351518, priorityId: 2}, eventModel: { form_id: "form_credityes-multipage", form_name: null, form_destination: "https://www.credityes.com/prequalify/", form_length: 53, first_field_id: "field_cy_multi_name_first", first_field_name: "item_meta[130]", first_field_type: "text", first_field_position: 1 }
{ event: "form_submit", gtm: {uniqueEventId: 0, start: 1675379351518, priorityId: 3}, eventModel: { form_id: "form_credityes-multipage", form_name: null, form_destination: "https://www.credityes.com/prequalify/", form_length: 67, event_callback: "Function" }, eventCallback: "Function" }

{ event: "form_start", gtm: {uniqueEventId: 0, start: 1675379379314, priorityId: 2}, eventModel: { form_id: "form_credityes-multipage", form_name: null, form_destination: "https://www.credityes.com/prequalify/", form_length: 52, first_field_id: "field_cy_multi_address", first_field_name: "item_meta[197]", first_field_type: "text", first_field_position: 1 } }

{ event: "form_submit", gtm: {uniqueEventId: 0, start: 1675379379314, priorityId: 3}, eventModel: { form_id: "form_credityes-multipage", form_name: null, form_destination: "https://www.credityes.com/prequalify/", form_length: 66, event_callback: "Function" }, eventCallback: "Function" }


 

1 Answers
Victor Font answered 1 year ago
Formidable does interact with window.dataLayer. The window.dataLayer is a JavaScript object used specifically by Google Tag Manager that you create yourself. Formidable has no awareness of objects you create yourself. You have to create the data transfers between Formidable and custom objects. Are you populating the data layer with dataLayer.push()?
Victor Font replied 1 year ago

Another thing to consider with tag manager is availability of data. If a gtag() or dataLayer.push() call is made by code on a page, in a Custom Template, or in a Custom HTML tag, the associated message is queued and processed after all other pending messages are evaluated. This means that any updated data layer values are not guaranteed to be available for the next event.

For Formidable to interact with your custom dataLayer, you should be using handlers that fire for form events. For each form element you want to track, you can use a jQuery on('change', function(){}) that pushed you values to the data upon every data change. Hope this helps.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right