CMS Development

JeffSchneider
Teilnehmer/-in | Gold Partner
Teilnehmer/-in | Gold Partner

Redirect to different success pages based on form dropdown selection

I'm trying to configure the form on this page so that depending on which option is selected in the dropdown field, it will send them to a different landing page:
https://info.marketingninjas.com/seg-evr-project-type

 

For example:

  • if the user selects the Homebuilder option, it will redirect to Landing Page A. 
  • if they select the Remodeler option, it will redirect to Landing Page B
  • and so on...

I found this code on a different thread that was trying to accomplish the same thing based on a checkbox field in the form:

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
	portalId: "#######",
	formId: "########",
	onFormSubmit: function($form) {
            if($form.find('input[name="current_giving_customer"]').prop('checked')){
                window.location.href = "https://google.com/";
            }else{
                window.location.href = "https://npr.org";
            }
        }
});
</script>

I understand the If/Else logic in the code above.  But is it possible to modify the code so that it will be:

  • If value = New Homes, then go to LP A
  • If value = Remodeling, then go to LP B
  • If value = Developer, then go to LP C
  • If value = Commercial, then go to LP D
  • If value = Other, then go to LP E
  • If value = Not a builder, then go to LP F

Thanks so much for your help. New to this and still learning. 

4 Antworten
OGagliardiJr
Mitglied

Redirect to different success pages based on form dropdown selection

I am new to hubspot.

 

Where do you place this code?

 

Thank you.

JLarsen1
Teilnehmer/-in

Redirect to different success pages based on form dropdown selection

I know it's been two years BUT if you or anyone else is looking for this - here's the solution:

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
	portalId: "#######",
	formId: "###########",
  onFormSubmit: function($form){
	        setTimeout( function() {
            var formval= $form.find('select[name="overall_how_satisfied_or_dissatisfied_are_you_with_our_company_"]').val();
       
     if(formval =="Very satisfied" || formval =="Somewhat satisfied"){
            window.location = "https://g.page/topjobasphalt/review?rc";
       } 
else{
  window.location = "https://topjobasphalt.com/thank-you-for-your-feedback/";        

}
          }, 250 ); // Redirects to url with query string data from form fields after 250 milliseconds.
      }
});
</script>


In our case, we send a customer satisfaction survey at the completion of a project, then anyone who says they are satisfied with the company will be sent to leave a review on Google. Otherwise, they will be sent to a thank you page.  

0 Upvotes
JLarsen1
Teilnehmer/-in

Redirect to different success pages based on form dropdown selection

I'm trying to do the same thing. Were you able to find something that works? I'm only finding solutions like the one you mentioned for a checkbox. 

Thanks

0 Upvotes
Mike_Eastwood
Autorität | Gold Partner
Autorität | Gold Partner

Redirect to different success pages based on form dropdown selection

Hi @JeffSchneider 

 

Haven't tried it myself BUT...

 

I would try the onFormSubmit or onFormSubmitted methods (see link) and to perform a redirect in a Switch/Case Statement.

 

https://developers.hubspot.com/docs/methods/forms/advanced_form_options

 

There may be some other JavaScript that could work for you.

 

Have fun

Mike