Pushing form data into data layer with JavaScript after form submit and before the redirect to the thank you page


is there a way with JavaScript to push form data into the data layer after the form is successfully submitted and before it redirects to the thank you page?