1b.app
Link copied -

How to add a GTM script to the head of contact forms?

Answers:

Good afternoon.
Made changes to saving the script in the form - check if your script is saved correctly.
23.05.2023, 14:46
Original comment available on version: ru

Валерия
Personal license

Tyndyk Maxim Vadimovich
OneBox production wrote:
Good afternoon.
Made changes to saving the script in the form - check if your script is saved correctly.

Thank you, we will try
24.05.2023, 09:39
Original comment available on version: ru

Валерия
Personal license
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.
24.05.2023, 19:24
Original comment available on version: ru

Please join the conversation. If you have something to say - please write a comment. You will need a mobile phone and an SMS code for identification to enter. Log in and comment