We would love to chat with you and learn how we can help elevate your brand with our full spectrum of services!
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('submit', function(event) {
if (event.target.matches('.elementor-form')) {
setTimeout(function() { // Delay to ensure form data is available
var emailField = document.querySelector("input[name='form_fields[email]']");
var firstNameField = document.querySelector("input[name='form_fields[first_name]']");
if (emailField && firstNameField) {
var emailValue = emailField.value.trim().toLowerCase();
var firstNameValue = firstNameField.value.trim();
// Hash the email using SHA-256 (Google requires this for Enhanced Conversions)
function hashEmail(email) {
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(email))
.then(hashBuffer => {
let hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
});
}
hashEmail(emailValue).then(hashedEmail => {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'elementorFormSubmission',
'email': hashedEmail, // Push the hashed email
'first_name': firstNameValue
});
console.log("Pushed to Data Layer:", {
'email': hashedEmail,
'first_name': firstNameValue
});
});
}
}, 500); // 500ms delay to allow form data to populate
}
}, true);
});