APIs & Integrations

techFA
Participant

Wordpress popup form not working

SOLVE

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.

0 Upvotes
1 Accepted solution
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Wordpress popup form not working

SOLVE

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: 

 

https://www.webalite.com/blog/hubspot-cos-design-tips-forms

 

Have fun

Mike

View solution in original post

2 Replies 2
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Wordpress popup form not working

SOLVE

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: 

 

https://www.webalite.com/blog/hubspot-cos-design-tips-forms

 

Have fun

Mike

techFA
Participant

Wordpress popup form not working

SOLVE

Thank you very much. It did work fine.

0 Upvotes