Override post-submit behavior of landing page forms
This functionality is available for Creatio 8.3.3 and later.
When a visitor submits a landing page form, the landing page shows default success or error messages. If you need full control over post-submit behavior, define custom actions for both outcomes via the Add script tab on a landing page in Creatio. For example, redirect visitors to a Thank you page, clear the form fields, show a custom popup, redirect visitors to another page, or fire tracking events.
Before you start, make sure the following parameters are configured in the landing page form's Block options in Landing Page Designer:
- the Block identifier toggle is enabled
- the ID field includes an ID that connects the script to the form. Use a unique value without spaces. For example: "Demo_Form." If the ID contains multiple words, use an underscore instead of a space.
Redirect visitors after successful submission
Use this to send visitors to a specific page after a successful form submission. For example, a Thank you page or a scheduling page.
To redirect visitors after successful submission:
-
Open the Lead Generation app and go to the Landing pages section.
-
Open the landing page you want to customize.
-
Go to the Add script tab.
-
Click Add script. This opens the Add script window.
-
Fill out the script parameters.
Parameter
Description
Name
An arbitrary script name. For example, "Redirect visitors script."
Position
Position in the page HTML. The position controls when the script loads and how it interacts with the rest of the page content. For this script, select "Body bottom." This ensures the script runs after all page content is loaded.
Script
<script type="text/javascript">
crtLanding.setFormConfig('ID_OF_SOME_LANDING_PAGE_FORM', {
redirectUrl: 'https://example.com/thank-you'
});
</script>Where:
ID_OF_SOME_LANDING_PAGE_FORMis the ID from the Block options of the landing page form in Landing Page Designer.redirectUrlis the URL where to redirect the visitor after a successful form submission. Use a full URL starting withhttps://.

-
Click Add script.
-
Click Publish to apply the changes.
As a result, visitors will be redirected to the specified URL after a successful form submission.
Run custom actions after successful submission
Use this to define what happens after the form is submitted successfully, instead of or in addition to the default success message.
To run custom actions after successful submission:
-
Open the Lead Generation app and go to the Landing pages section.
-
Open the landing page you want to customize.
-
Go to the Add script tab.
-
Click Add script. This opens the Add script window.
-
Fill out the script parameters.
Parameter
Description
Name
An arbitrary script name. For example, "Success post-submit popup script."
Position
Position in the page HTML. The position controls when the script loads and how it interacts with the rest of the page content. For this script, select "Body bottom." This ensures the script runs after all page content is loaded.
Script
<script type="text/javascript">
crtLanding.setFormConfig('ID_OF_SOME_LANDING_PAGE_FORM', {
onSuccess: (form, formConfig) => {
/* Add your custom logic here, e.g., clear the form fields,
show a custom popup, redirect to another page, or send tracking events. */
}
});
</script>Where:
ID_OF_SOME_LANDING_PAGE_FORMis the ID from the Block options of the landing page form in Landing Page Designer.onSuccessis the function that runs when the form is submitted successfully. Add your custom logic inside theonSuccessfunction body.formis the form DOM element. Use it to access or manipulate the form directly, for example, to clear the fields.formConfigis the form configuration object.

-
Click Add script.
-
Click Publish to apply the changes.
As a result, the custom logic will run every time the form is submitted successfully.
Run custom actions after failed submission
Use this to define what happens when a form submission fails, instead of or in addition to the default error message.
To run custom actions after failed submission:
-
Open the Lead Generation app and go to the Landing pages section.
-
Open the landing page you want to customize.
-
Go to the Add script tab.
-
Click Add script. This opens the Add script window.
-
Fill out the script parameters.
Parameter
Description
Name
An arbitrary script name. For example, "Error post-submit script."
Position
Position in the page HTML. The position controls when the script loads and how it interacts with the rest of the page content. For this script, select "Body bottom." This ensures the script runs after all page content is loaded.
Script
<script type="text/javascript">
crtLanding.setFormConfig('ID_OF_SOME_LANDING_PAGE_FORM', {
onError: (form, formConfig, message) => {
/* Add your custom logic here, e.g., show a custom error notification,
log the error for debugging, or highlight required fields. */
}
});
</script>Where:
ID_OF_SOME_LANDING_PAGE_FORMis the ID from the Block options of the landing page form in Landing Page Designer.onErroris the function that runs when the form submission fails. Add your custom logic inside theonErrorfunction body.formis the form DOM element. Use it to access or manipulate the form directly, for example, to highlight required fields.formConfigis the form configuration object.messageis the error text returned by the server. Use it to display the error to the visitor or for debugging.

-
Click Add script.
-
Click Publish to apply the changes.
As a result, the custom logic will run every time a form submission fails.
See also
Landing pages (user documentation)