window.addEventListener('message', event => { if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') { someAnalyticsLib('formSubmitted'); console.log("Form Submitted!"); } });