Tagged: tag manager
Although I found several threads on this I’m still not sure how to correctly track succesfully submitted contact forms with Tag Manager.
I managed to identify the following for my Tag Manager settings:
Class element: [object HTMLInputElement]
Form Classes: button
But now I’m measuring all clicks on the button of the form, not just the succesfully send forms, I can’t find any identificator for this in the GTM debugger.
I’m quite new to this, so perhaps you could provide me with a step by step progress of this?
I found this thread and added the code to the function.php file, but I’m really not sure how this can help me with my problem?
https://kriesi.at/support/topic/tracking-contact-form-in-google-tag-manager/
Hey NewbieEnfold,
The code shared here adds an attribute to the submit button of the contact form. So it will track the contact form submissions.
https://kriesi.at/support/topic/tracking-contact-form-in-google-tag-manager/#post-429580
You can try adding the code for the submit event instead:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3);
function avia_add_submit_attributes_to_cf($att, $formID, $form_params){
$att = "onsubmit =\" dataLayer.push({'event': 'form-submission'}); \"";
return $att;
}
Best regards,
Victoria
Dear Victoria, thx, where would I need to add this?
With the code you propopse, I could track the even ‘form-submission’ in GTM?
I’m stuck with this with two sites (and counting) that I build with Enfold, so would be great to get as much insight/details as possible :)