# Different redirect URLs after form submitted (Custom Form Embed Code)

**URL:** <https://community.hubspot.com/t/different-redirect-urls-after-form-submitted-custom-form-embed-code/82865>\
**Category:** CMS Development\
**Tags:** developer, forms\
**Created:** [June 7, 2023, 2:48pm UTC](https://community.hubspot.com/t/different-redirect-urls-after-form-submitted-custom-form-embed-code/82865 "2023-06-07T14:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickbudjml](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nickbudjml/32/25270_2.png) [@nickbudjml](https://community.hubspot.com/u/nickbudjml)\
**Post date:** [June 7, 2023, 2:48pm UTC](https://community.hubspot.com/t/different-redirect-urls-after-form-submitted-custom-form-embed-code/82865/1 "2023-06-07T14:48:37Z")

</div>

Hey brilliant peers!

Looking for advice on adding custom javascript calls on Form Submissions in the form embed code on our website.  
Goal: redirect the post-submission thank you page to different URLs based on the input fields upon form submission. (Variable landing pages)  
I saw this post: [https://community.hubspot.com/t5/Lead-Capture-Tools/Single-form-for-multiple-pages-multiple-thank-you-pages/m-p/494326/thread-id/6425](https://community.hubspot.com/t5/Lead-Capture-Tools/Single-form-for-multiple-pages-multiple-thank-you-pages/m-p/494326/thread-id/6425)  
And read through this article: [https://legacydocs.hubspot.com/docs/methods/forms/advanced\_form\_options](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options)  
And built my first pass at the javascript code in our embed:  
~~start~~

```lia-code-sample
onFormSubmitted: function($form) {
if (
(
document.querySelector("input[name='customer_input_revenue']").value = "Over $500M"
)
) {
// if field value is a specific results, then set value of redirectUrl to a hardcoded URL I desire
redirectUrl.value = "https://aidaptive.com/nickbudincich-redirect-case-1" ;
return redirectUrl ;
} else {
// Otherwise, set value of redirectUrl to a default hardcoded URL I desire
redirectUrl.value = "https://aidaptive.com/nickbudincich-redirect-else" ;
return redirectUrl ;
}
}​

```

~~end~~  
(see pic)  
I’m sure this is super simple, it’s just a matter of syntax and I’m not a pro.  
**Is there someone who can point me to the right resource? Or someone who can comment on the right syntax?**  
The logic is straightforward:

- Upon form Submitted \>
- IF ( field input is \_\_\_ )
- THEN (set the redirect URL to case 1 )
- OTHERWISE (set to default redirect URL)  
Thank you SO much!

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 7, 2023, 3:50pm UTC](https://community.hubspot.com/t/different-redirect-urls-after-form-submitted-custom-form-embed-code/82865/2 "2023-06-07T15:50:28Z")

</div>

Hey @nickbudjml

As someone with a huge amount of experience in HubSpot forms, I’d always recomend against customising the embed code tbh. Even the onFormSubmitted still runs the risk of redirecting the page before the HS submission happens. But if you need to do it you need to do it!

My Js is a bit rusty but this does seem very straightforward, visitors should be redirected to [Aidaptive - Adaptive AI for Business](https://aidaptive.com/nickbudincich-redirect-case-1) if they input a value for the property “customer\_input\_revenue” of “over $500m” right?  
I would expect this to work, but it’s impossible to troubleshoot why it’s not working without having an example, what exactly is happening that is unexpected when you do this? Do you have an example page of this not working as expected?
