Lists, Lead Scoring & Workflows

Jonnydk
Colaborador líder

Multi Step Forms - Possible??

resolver

Hi is it possible to achieve a "multi-step" form through hubspot. The first part of the form would be the basics, First Name, Last Name, Work Email and Company Name. Once the user clicks "Next" we would ask them to fill in more details. If they leave before or after next we will capture their info and assign them to a lifecycle stage and if they finish the next step we will qualify them for a sales call. Is this possible, if so how can I achieve this? TYIA Corazón

1 Soluciones aceptada
thesnappingdog
Solución
Colaborador

Multi Step Forms - Possible??

resolver

hey I don't know if anyone's still looking for a solution to this. 

 

I wrote a how to + shared the code for creating 2 step forms.

 

However with this method you can chain any amount of forms if you want, it's just nicer to split the code into neat functions rather than what is done in the how-to.

 

hopefully this helps someone!

 

how-to:

 https://hyper-typed-marketing.mailchimpsites.com/growth-multistep-forms-hubspot

code: https://gist.github.com/thesnappingdog/44e470c160e13d3208ad5cf613027a47

 

P.S. this works without hiccups except that... completing two step form counts as.. two form submissions 😄 

 

Edit: I made a multi step generator so nobody has to painfully copy paste code. see other reply for more details: 

 

https://github.com/thesnappingdog/hubspot-multistep-form-generator

Ver la solución en mensaje original publicado

67 Respuestas 67
sboi
Participante

Multi Step Forms - Possible??

resolver

here is the html code of the page , which has the above in it.

<!--
  templateType: "page"
  isAvailableForNewContent: true
-->
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="{{ html_lang }}" {{ html_lang_dir }}> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="{{ html_lang }}" {{ html_lang_dir }}>        <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="{{ html_lang }}" {{ html_lang_dir }}>               <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="{{ html_lang }}" {{ html_lang_dir }}> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="author" content="{{ meta_author }}">
    <meta name="description" content="{{ page_meta.meta_description }}">
    <meta name="generator" content="HubSpot">
    {% if page_meta.html_title %}<title>{{ page_meta.html_title }}</title>{% endif %}
    {% if site_settings.favicon_src %}<link rel="shortcut icon" href="{{ site_settings.favicon_src }}" />{% endif %}
    
{{ required_head_tags }}
    
    {{ include_css("/hubspot_default/shared/responsive/layout.css") }}
    {{ user_head_overrides }}

</head>
<body class=" {{ builtin_body_classes }}" style="">
    <div class="header-container-wrapper">
    <div class="header-container container-fluid">


    </div><!--end header -->
</div><!--end header wrapper -->

<div class="body-container-wrapper">
    <div class="body-container container-fluid">


    </div><!--end body -->
</div><!--end body wrapper -->
<div id="demo-form"></div>
    <script>
      var data = []
      hbspt.forms.create({
      portalId: "INSERT_PORTAL_ID ",
      formId: "INSERT_FORM_ID",
      target: "#demo-form",
      onFormSubmit: function(form) {
      var incoming = $(form).serializeArray();
      data.push(incoming);
      },
          onFormSubmitted: function(form) {
          $('#demo-form').empty();
          hbspt.forms.create({
          portalId: "INSERT_PORTAL_ID  ",
          formId: "INSERT_FORM_ID ",
          target: "#demo-form",
          onFormReady: function(form) {
          form.find('input[name="email"]').val(data[0].value).change();
          } 
          })
          }
      });
     </script>
<div class="footer-container-wrapper">
    <div class="footer-container container-fluid">


    </div><!--end footer -->
</div><!--end footer wrapper -->

    {{ standard_footer_includes }}
    
    <!-- Generated by the HubSpot Template Builder - template version 1.03 -->
</body>
</html>
0 Me gusta
elanashama
Colaborador líder

Multi Step Forms - Possible??

resolver
You need to insert your hubspot account portal ID and the relevant form IDs. Have you done that?

0 Me gusta
sboi
Participante

Multi Step Forms - Possible??

resolver
Yes I have done that
0 Me gusta
elanashama
Colaborador líder

Multi Step Forms - Possible??

resolver

do you have jquery enabled on your pages? 

0 Me gusta
sboi
Participante

Multi Step Forms - Possible??

resolver

I have enabled jQuery now , however i now get complete blank page in preview

0 Me gusta
elanashama
Colaborador líder

Multi Step Forms - Possible??

resolver
This is the extent of my knowledge in this area. Sorry I can’t be of more help.
SimonKay
Miembro

Multi Step Forms - Possible??

resolver

Thanks for this - I'm running your code above (and have elongated it to 5 forms) and it's showing them sequentially front end (on my Wordpress site). However the data is only being captured in HubSpot for the first form submission – it's as though it's not linking the other 4 forms that follow to the Contact record.

I've replaced the $ (dollar sign) with "jQuery" as suggested by @thesnappingdog in his original article and have played aorund with both the original array level and your suggested depper array @squatchcreative.

 

Is there anything else I should look at to ensure that the email is being handed off correctly between forms?

(Evidentally, I'm not a JS pro, so appreciate the help!)

0 Me gusta
squatchcreative
Colaborador

Multi Step Forms - Possible??

resolver

@SimonKay  It's impossible to troubleshoot your issue without seeing your code.  Were you having success with it working as 2 steps before you turned it into 5 steps? I would start there before you added to the complexity of the form.  Begin with two forms, use @thesnappingdog example, and see if that works.   Find out if it is handing off the email to the next form with just 2. If it doesn't, post that code, and any errors in your console when it doesn't work.  If it does work, try 3, and so on.  

 

My example and his example traverse down a Javascript array differently, so which one are you using?  Did you try the other?  Try outputting the email variable to your console log -- see what it says.  Is it blank?  Does it output the email correctly?  When you go to the 2nd step, inspect your email field.... did it place the email value in there for you?  You need to check all of these things to make sure you are actually passing the email variable.

 

Good luck. 

SimonKay
Miembro

Multi Step Forms - Possible??

resolver

I appreciate that, thanks @squatchcreative. Code below this.

I tried scaling from 2, to 3,4,5 forms. On all fronts, the form progressed through the sequence (i.e. on submit, I was able to see and complete the next form), however HubSpot is only recording the data submitted from the FIRST form. As though it's not attributing the following forms with that Contact – and therefore isn't passing the email variable.

I tried with both array options. I also altered the JS script link (as mentioned in the thread) and played with switching the "$" vs. "jQuery" variables (you'll see I landed on the latter in my code below, since this actually allowed the forms to appear one after another).

So it would appear the issue is the email hand-off.

 

Thanks for your help – much appreciated.

 

 

<div id="form-container"></div>
<script charset="utf-8" type="text/javascript" src="https://js.hsforms.net/forms/v2.js"></script>
<script>
	var data = [];

	hbspt.forms.create({
		portalId: "XXXX",
		formId: "XXXX",
		target: "#form-container",
		onFormSubmit: function(form) {
			var incoming = jQuery(form).serializeArray();
			data.push(incoming);
		},
		onFormSubmitted: function(form) {
			jQuery('#form-container').empty();
			hbspt.forms.create({
				portalId: "XXXX",
				formId: "XXXX",
				target: "#form-container",
				onFormReady: function(form) {
					form.find('input[name="email"]').val(data[0].value).change();
				},
				onFormSubmitted: function(form) {
					jQuery('#form-container').empty();
					hbspt.forms.create({
						portalId: "XXXX",
						formId: "XXXX",
						target: "#form-container",
						onFormReady: function(form) {
							form.find('input[name="email"]').val(data[0].value).change();
						},
						onFormSubmitted: function(form) {
							jQuery('#form-container').empty();
							hbspt.forms.create({
								portalId: "XXXX",
								formId: "XXXX",
								target: "#form-container",
								onFormReady: function(form) {
									form.find('input[name="email"]').val(data[0].value).change();
								},
								onFormSubmitted: function(form) {
									jQuery('#form-container').empty();
									hbspt.forms.create({
										portalId: "XXXX",
										formId: "XXXX",
										target: "#form-container",
										onFormReady: function(form) {
											form.find('input[name="email"]').val(data[0].value).change();
										}
									})
								}
							})
						}
					})
				}
			})
		}
	});
</script>

 

thesnappingdog
Colaborador

Multi Step Forms - Possible??

resolver

I remember running into this problem as well when building the proto:

 

var incoming = $(form).serializeArray();
data.push(incoming);
form.find('input[name="email"]').val(data[0][0].value).change();

 

I think it started happening if i $(form).serializeArray multiple times, then the data var ended up having other arrays in it :S 

0 Me gusta
thesnappingdog
Colaborador

Multi Step Forms - Possible??

resolver

that's awesome @squatchcreative @rwolupo ! I was thinking about this yesterday, and specifically how @squatchcreative you probably had to do a lot of copypasting with a 6 step form.. I'm gonna try to make a multi-step generator so that you guys only need to edit a formId array, target and portal id. 

 

At the end of the day hbspt.forms.create() just needs an object with info and it should be possible to make that programmatic (first step options, inbetween, last form options)

thesnappingdog
Colaborador

Multi Step Forms - Possible??

resolver

hey @Jonnydk @rwolupo @squatchcreative @elanashama can I ask you to be pilots for something.

 

Long story short, I made a generator that does all the work you'd have to do with my previous code. It will create as many steps as you have forms.

 

Now you just need to edit:

 

- forms = [form1, form2, etc]

- target = 'container id'

- portalId = 'your portal id'

 

It worked flawlessly for me on a Chrome browser, each steps' submission was recorded in the CRM. I tried with 3 forms, then with 4. It's written in more modern javascript so if this works well I could see what the code would be in old timey script.

 

https://github.com/thesnappingdog/hubspot-multistep-form-generator

 

Please see the README.md before implementing and please let me know if there's bugs / errors either here or on github 🙏

rwolupo
Colaborador líder

Multi Step Forms - Possible??

resolver

thx @squatchcreative 

it worked for me - except of the form.find thing ... i had to use the orginal code from @thesnappingdog 

thesnappingdog
Solución
Colaborador

Multi Step Forms - Possible??

resolver

hey I don't know if anyone's still looking for a solution to this. 

 

I wrote a how to + shared the code for creating 2 step forms.

 

However with this method you can chain any amount of forms if you want, it's just nicer to split the code into neat functions rather than what is done in the how-to.

 

hopefully this helps someone!

 

how-to:

 https://hyper-typed-marketing.mailchimpsites.com/growth-multistep-forms-hubspot

code: https://gist.github.com/thesnappingdog/44e470c160e13d3208ad5cf613027a47

 

P.S. this works without hiccups except that... completing two step form counts as.. two form submissions 😄 

 

Edit: I made a multi step generator so nobody has to painfully copy paste code. see other reply for more details: 

 

https://github.com/thesnappingdog/hubspot-multistep-form-generator

sboi
Participante

Multi Step Forms - Possible??

resolver

Hi ,can you help on this i have tried mutipage form as below ,however it is not loading at all.

<!--
    templateType: page
    isAvailableForNewContent: true
-->
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">

   
    {{ standard_header_includes }}
  </head>
  <body>
    {% dnd_area "dnd_area"
      label="Main section"
    %}
      {% dnd_section %}
        {% dnd_column %}
          {% dnd_row %}

            {% dnd_module path="@hubspot/logo" %}
            {% end_dnd_module %}

          {% end_dnd_row %}
          {% dnd_row %}

            {% dnd_module path="@hubspot/rich_text" %}
            {% end_dnd_module %}

          {% end_dnd_row %}
        {% end_dnd_column %}
      {% end_dnd_section %}
    {% end_dnd_area %}
    {{ standard_footer_includes }}
    
    <div id="demo-form"></div>
    <script>
      var data = []
      hbspt.forms.create({
      portalId: "XXXXXX",
      formId: "XXXXXX",
      target: "#demo-form",
      onFormSubmit: function(form) {
      var incoming = $(form).serializeArray();
      data.push(incoming);
      },
          onFormSubmitted: function(form) {
          $('#demo-form').empty();
          hbspt.forms.create({
          portalId: "XXXXXX",
          formId: "XXXXXXX",
          target: "#demo-form",
          onFormReady: function(form) {
          form.find('input[name="email"]').val(data[0].value).change();
          } 
          })
          }
      });
     </script>
  </body>
</html>
0 Me gusta
elanashama
Colaborador líder

Multi Step Forms - Possible??

resolver

Hi @thesnappingdog ,

 

Is there a way to add a "previous" button to the second form, so that someone can go back to the first form? Also, when doing so, would the user lose all data inserted into the second form? 

0 Me gusta
DigitalKris
Participante | Partner
Participante | Partner

Multi Step Forms - Possible??

resolver

This is great work! Really glad I found it. Thank you so much!

soumyadipdutta8
Miembro

Multi Step Forms - Possible??

resolver

Hello @thesnappingdog 

 

If I have only HTML form with multistep funcanality can I submit the HTML form data to hubspot using API?

0 Me gusta
thesnappingdog
Colaborador

Multi Step Forms - Possible??

resolver

hey @soumyadipdutta8 im not sure i understand the question. please elaborate. You mean like if you have an actual <form></form> which is not a hubspot rendered form? 

 

If yes, looks like its possible, but youd still need a form ID from hubspot

 

https://legacydocs.hubspot.com/docs/methods/forms/submit_form

JFarías
Miembro

Multi Step Forms - Possible??

resolver

Hey @soumyadipdutta8 and @thesnappingdog, did you know how to do something like this? descubre.capitalizarme.com/ab/7f01231e

 

I know.. is very ugly.. but i need to make this function on hubspot first.. after that i will find the way to make it pretty pretty 😂

0 Me gusta
soumyadipdutta8
Miembro

Multi Step Forms - Possible??

resolver

Hello @thesnappingdog 

 

I have created 3 seperate forms in hubspot and marge them using your codebase. But after submission of final step I got 3 seperate email response in my mailbox with submitted data which I have already submitted. I want a single mail for all the steps. Can you please help me?

0 Me gusta