Step 2 - What does the code mean?
Without further ado, let’s take a look at the code:
Or check here
There are 3 main sections in this code:
1. Only applicable to people who use internet explorer for whatever reason:
<!--[if lte IE 8]>
What happens there: If the users’ browser is IE 8, we will use the hubspot v2-legacy code.
2. A script that tag loads up HubSpots form functionality to your browser:
What happens there: By default, load up the HubSpot forms functionality into your browser, so that we can ask their functions to do stuff (like.. Create forms ;) )
3. And lastly, the beef. Code that we execute when the page loads. This is the part of the code that tells the HubSpot form functionality what to do.
Okay, this one I would like to break down even further, especially if you’re new to how stuff works on the internet. This is important.
Firstly, the script tag:
OK next we have this thing:
Let’s imagine a simple mind-map. The center of the mindmap is “hbspt” - and from there there are many nodes connected to it.
One of those nodes is called “forms” - which houses important instructions for hubspots form features. I don’t know exactly what kind of nodes are actually connected to “forms” but I do know that there is one node called… “create”.
Say the create node was a button. If I click it, what happens?
You guessed it - a form is created. Or at least, it will try to ;)
OK now we understand that we first need to “start” the HubSpot forms functionality by loading it up into the browser. Then we know we have to ask that functionality to create a form for us - but how does HubSpot know the form belongs to me and my portal?
The create function expects parameters, so we just tell it what's what ;)
What you see inside of those curly brackets are called options. If we give the correct options, we should get the correct form.
= your HubSpot portal id
= the ID of the form you created
These two options will be automatically generated when you publish your form. However, it’s also useful to understand where you can get these from.
So in other words, if you wanted to, you could create a form for someone else if you knew their portal ID and the formID. However, I don’t encourage that kind of behaviour ;)
And lastly, a short note on customising the embed code:
Earlier I mentioned that the key to multi-step forms lies within the embed code. You see, portalID and formID are not the only options that we can give to HubSpot - in fact there’s a bunch more that you can use
target: “THE PLACE IN THE PAGE THIS SHOULD GO TO”