Wordpress popup form not working

Hi, I need help integrating my form into my wordpress page, I am creating a popup with the embedded form code, but everytime I try it gives me this error:

TypeError: hbspt.forms.create is not a function

I tried inserting the script into the header but no success.

Here is the popup HTML

<div id=“ppsPopupShell_[ID]” class=“ppsPopupShell ppsPopupListsShell”>
<a href=“#” class=“ppsPopupClose ppsPopupClose_[close_btn]”></a>
<div class=“ppsInnerTblContent”>
<div class=“ppsPopupListsInner ppsPopupInner”>
<div class=“ppsPopupLabel ppsPopupListsLabel”>[label]</div>
<div style=“clear: both;”></div>

<script>
hbspt.forms.create({
portalId: “xxxxxxx”,
formId: “xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx”
});
</script>
<div style=“clear: both;”></div>
</div>
</div>
</div>

I am using a button to display the popup, everytime I remove the embedded code it loads just fine, but when I reinsert it, it just crashes.

Hi @techFA

Looks to me like your Embed Code is firing before your HubSpot Javascript is loaded.

Assuming you’ve installed the HubSpot Plugin and there are no serious Javascript errors on the page.

I would try this:

...
<script>
window.onload = function() {
 hbspt.forms.create({
 portalId: "xxxxxxx",
 formId: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
 });
}
</script>
...

And, to be safe, I’d add a Target Div ID.

Have a look at this page:

Have fun

Mike

Thank you very much. It did work fine.