document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector('.form_generater_form_div form'); // Update with your form's selector if necessary
if (form) {
form.addEventListener('submit', function(event) {
event.preventDefault(); // Prevents default form submission so you can handle it in GTM
// Push event to the dataLayer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "hulkFormSubmission",
formName: "hulk forms",
formFields: {
nombre: document.querySelector('#form_input_0').value,
empresa: document.querySelector('#form_input_1').value,
ocupacion: Array.from(document.querySelectorAll('.checkboxmulti_2:checked')).map(checkbox => checkbox.value),
correo: document.querySelector('#form_input_3').value,
telefono: document.querySelector('#form_input_4').value,
mensaje: document.querySelector('#form_input_5').value
}
});
// Optionally, submit the form or trigger other actions after pushing dataLayer event
form.submit();
});
}
});