How to install the scheduler script?
Here are the steps that would help you embed the RevenueHero widget on your thank you pagepage.
Install widget on a thank you page
Ensure the following:
- Disable redirection for the form.
- The redirection link must be from the same domain as the form page.
There are two parts to the setup:
- Installing the script on the form page.
- Installing the script on the thank you page.
On the form page
- Paste this script after your form.
<script>
//Replace formID with your form's ID
document.querySelector("#formID").addEventListener("submit", (e) => {
// Collect form field values
const rhSubmitData = Object.fromEntries(new FormData(e.target).entries());
// Store data in localstorage because page is going to redirect. Replace routerID.
localStorage.setItem('rhdata', JSON.stringify(rhSubmitData));
localStorage.setItem('rhid', 'routerID');
//Set redirection link to thank you page. Replace with your URL.
window.location.href = "https://redirect.com";
});
</script>
- Replace the following in the aformentioned script:
Find in snippet | Replace with |
---|---|
formID | your form’s ID |
routerID | your router’s ID |
redirect.com | your thank-you page URL |
On the thank you page
- Paste this script in your page’s
<body>
.
<script type="text/javascript" src="https://app.revenuehero.io/scheduler.min.js"></script>
<script>
//retrieve the data from local storage
var revdata = localStorage.getItem('rhdata');
if(revdata !== null) {
var jsonData = JSON.parse(revdata);
//pass the data to RevenueHero and call the scheduler
window.hero = new RevenueHero({ routerId: localStorage.getItem("rhid") })
hero.submit(jsonData).then(function(sessionData) {
hero.dialog.open(sessionData);
//delete the data from local storage
localStorage.removeItem("rhdata");
localStorage.removeItem("rhid");
});
}
</script>
- You’re all set!