Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to embed a hubspot form in an external site

Hi I'm following hubspot's documentation on how to embed a form on an external site

According to documentation, one needs to include the javascript

<!--[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>

and to create the form

<script>
  hbspt.forms.create({ 
    portalId: '2089699',
    formId: '287337b2-e8a6-4eaa-b293-bbd3d3622d8a'
  });
</script>

And that's as far as the documentation goes. I do this and nothing is happening. Seems that at least I would need to tell hubspot where to put the form, right?... very strange.

Can anyone enlighten me on this one? What am I missing?

like image 302
Martin Massera Avatar asked Oct 26 '25 15:10

Martin Massera


1 Answers

Ok, answering my own question!

What's needed is the target option to tell hubspot where to put the form:

<script>
hbspt.forms.create({ 
    portalId: '2089699',
    formId: '287337b2-e8a6-4eaa-b293-bbd3d3622d8a',
    target: '#my_form',
});
</script>
like image 72
Martin Massera Avatar answered Oct 29 '25 03:10

Martin Massera