Note: You can only add JavaScript to the Thank You page if the script is included in a .js file and uploaded on a server. In the Settings → Advanced section of your form, go to Form → Scripts and select the option Add a JS script to the Thank You page of your form. An input field will drop down requesting the URL of your script.
Paste the URL of the script in the box and hit Save. This will trigger your script after your form users have submitted the web form.