Form not showing up on website

ksweet5533
Member

I'm using a hubspot form (free version). Here is what I did:

1. create form in hubspot

2. copy code

3. paste code into squarespace site as instructed here: https://www.youtube.com/watch?v=5z_G3jwzpgI

4. clicked save

 

When I visit the site from the navigation, I do not see the form. When I click refresh, the form appears. The URL is identical before and after refresh. 

 

Trying to figure out why the form would not show before the refresh but would after.

 

Thanks in advance!

5 Replies 5
jpsanchez
Top Contributor | Gold Partner

Can you share the url where is embed?..

 

Thanks

JP

0 Upvotes
naomi_g
Participant

Hi there, I am having the same issue as you. Did you ever find a solution? Thanks!

0 Upvotes
hubbub
Participant

I have the same problem. I also have free Hubspot.

 

This is what I tried:

 

First, I copy & pasted the exact code that Hubspot told me to use into code on my Squarespace website. With this code (see below for a generic version without my particular numbers), the form wasn't displaying at all:

 

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/shell.js"></script>
<script>
hbspt.forms.create({
portalId: "my number here",
formId: "my number here"
});
</script>

 

Second, I found a message board post telling me to modify the code (see below for the generic modified version that doesn't have my particular numbers in it yet). The reason for modifying the code had something to do with loading times, but I'm not website-savvy enough to understand the details, and I couldn't find the forum post again to share with you now.

 

<div id="divFormHolder">
<!--[if lte IE 8]>

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js" defer></script>

<![endif]-->

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js" defer></script>

<script>

window.onload = function() {
hbspt.forms.create({

portalId: 'my id here',

formId: 'my number here',

target: "#divFormHolder",

});

};

</script>

</div>


With this second batch of code, the form still does NOT load when I initially go to the page. However, when I REFRESH the page, the form appears, which sounds like what's happening to ksweet 5533.

 

Does anyone have any solutions for this problem so that visitors don't have to refresh the page to see the form?

0 Upvotes
Tom
HubSpot Product Team
HubSpot Product Team

Hey @ksweet5533  I've seen issues like this creep up in the past with squarespace. It's caused by their ajax loader. This loads all scripts on first page load and doesn't reload them when clicking around the website. This causes the site to load faster, but it also means the form creation script doesn't fire when you click around the site, so the page doesn't load.

 

There's more info on this and how to disable this on squarespace's community: https://forum.squarespace.com/topic/87058-why-doesnt-my-javascript-code-work-until-i-refresh-the-pag...

hubbub
Participant

I disabled Ajax on my site, and I'm still having the same issue. The form doesn't load until I refresh the page.

 

Any other thoughts or suggestions?

0 Upvotes