Igor Ustimenko Code added, everything works. But now another question: what event is fired after a successful form submission?
I added this code to the Insert code in HEAD field after successful submission:
<script>
(function() {
// Find the success message or element identifier
var successElement = document.querySelector('.alert-success');
// Check if the success message or element exists
if (successElement) {
// Fire the event after a slight delay to ensure the message is displayed
setTimeout(function() {
// Push the event to the data layer
dataLayer.push({
'event': 'formSubmission',
'eventCategory': 'Form',
'eventAction': 'Successfully completed form'
});
}, 500); // Delay time
}
})();
</script>
But nothing happens. Success tracking is bound to an element with the .alert-success class. But dataLayer is empty after successful submit
which event to bind to? I looked at the server's response, but I can't find anything there either.