Custom scripts can be added under Configure → Analytics in the form editor. Scripts entered under "Page load scripts" will be fired as soon as the form is opened, and "successful submission scripts" will fire after the form is completed. Make sure that all JavaScript is wrapped inside of HTML <script> tags.
If you're using selected pricing plans, you can also add a script to a specific Dynamic Success Page. Go to After Submission → Success Pages & Redirects → Dynamic Success Pages & Redirects, then create or edit the page. Add a custom HTML block, then paste your script inside of <script> tags.