var form = document.querySelector('#cf_1'); form.addEventListener('success', function(event) { dataLayer.push({ 'event': 'myFormSubmission' }); });