You have found the right people. Discussing your PR and marketing challenges is our favourite things to do!
Let us know what you want to achieve, and we will be in touch.
Let’s connect and transform your PR and marketing with impactful and insightful strategies. Email us at info@cartwrightcommunications.co.uk, and we will be in touch in no time!
Prefer to chat on the phone? Give us a call on0115 853 210
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);
});