Skip to main content
Version: 8.3

Override post-submit behavior of landing page forms

note

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:

  1. Open the Lead Generation app and go to the Landing pages section.

  2. Open the landing page you want to customize.

  3. Go to the Add script tab.

  4. Click Add script. This opens the Add script window.

  5. 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_FORM is the ID from the Block options of the landing page form in Landing Page Designer.
    • redirectUrl is the URL where to redirect the visitor after a successful form submission. Use a full URL starting with https://.
  6. Click Add script.

  7. 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:

  1. Open the Lead Generation app and go to the Landing pages section.

  2. Open the landing page you want to customize.

  3. Go to the Add script tab.

  4. Click Add script. This opens the Add script window.

  5. 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_FORM is the ID from the Block options of the landing page form in Landing Page Designer.
    • onSuccess is the function that runs when the form is submitted successfully. Add your custom logic inside the onSuccess function body.
    • form is the form DOM element. Use it to access or manipulate the form directly, for example, to clear the fields.
    • formConfig is the form configuration object.
  6. Click Add script.

  7. 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:

  1. Open the Lead Generation app and go to the Landing pages section.

  2. Open the landing page you want to customize.

  3. Go to the Add script tab.

  4. Click Add script. This opens the Add script window.

  5. 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_FORM is the ID from the Block options of the landing page form in Landing Page Designer.
    • onError is the function that runs when the form submission fails. Add your custom logic inside the onError function body.
    • form is the form DOM element. Use it to access or manipulate the form directly, for example, to highlight required fields.
    • formConfig is the form configuration object.
    • message is the error text returned by the server. Use it to display the error to the visitor or for debugging.
  6. Click Add script.

  7. 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)