1. Home
  2. Code Snippets for Adding a Thank You Alert Upon Form Submission

Code Snippets for Adding a Thank You Alert Upon Form Submission

The following script can be utilized to add a custom ‘Thank You’ message to PathFactory experiences upon form submission. This script is using PathFactory’s Dispatch Jukebox Events which can be used to trigger other functions in PathFactory. In particular, the ‘submit_external_form’ event is being used to fire the alert.

To see more examples of code snippets, read Frequently Used External Code Snippets to Personalize Your PathFactory Experiences.

See This Code In Action

Where to place the script?

This script can be added through your External Code library and you can find a step by step guide on how to do so here are specific instructions on how to do so. The location can be set to ‘Head Tag’ and be applied to any Experience within your PathFactory instance.

In the code below, the underlined text can be modified to your liking. The code that is bolded is where you would indicate the time you want the alert to appear after the form is submitted. If you want the message to be delayed, you may modify this time. 

Code Snippet

<script>

handleJukeboxDispatchedEvents = function(event) {

     switch (event.detail.eventName) {

       case “submit_external_form”:

           setTimeout(function(){ window.alert(“Thank you for filling out our form! We appreciate your interest and will be in touch soon.“); }, 1000);

}

     };

     window.addEventListener(“pf_event”, this.handleJukeboxDispatchedEvents, false);

   </script>

Views: 0

Updated on July 27, 2023

Was this article helpful?

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT