document.querySelector('form').addEventListener('submit', function(event) {
// Prevent default action if needed
// event.preventDefault();
// Extract form data
const formData = new FormData(event.target);
const data = {};
formData.forEach((value, key) => {
data[key] = value; // Key-value pair of form fields
});
// Push data to the GTM Data Layer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'formSubmit',
formData: data
});
});