Hubspot script not working in cookie consent

Description

When I let FS Components Cookie Consent update my Hubspot codes, the Hubspot forms are not showing. If I change it back to normal, they show again. What’s the problem here? I have changed them back to normal, otherwise the site is not functional.

Site URL

The forms are on the for example /contact page.

This is my original Hubspot code:

When I let it change by Finsweet cookie consent component, and replace these 2 scripts, the form is not visible.

Thanks!

Hey @pim!

I assume you’re referring to these scripts inside an embed element:

<script
  charset="utf-8"
  type="text/javascript"
  src="//js-eu1.hsforms.net/forms/embed/v2.js"
></script>
<script type="text/javascript">
  hbspt.forms.create({
    region: 'eu1',
    portalId: '143476855',
    formId: 'a65ebb87-1eb8-4d86-ac0b-c9c9efc27967',
  });
</script>

The reason the form disappears is likely that these scripts have been categorized under a consent category, preventing them from loading if a user has not accepted consent.

From my research, these scripts do not issue any cookies, so they can either be marked as Essential or dismissed within the app.

However, the script that should always be categorized is this one, which is correctly set to the Marketing category:

<!-- This script is managed by Finsweet Cookie Consent -->
<script
  type="fs-consent"
  id="hs-script-loader"
  async=""
  defer=""
  src="//js-eu1.hs-scripts.com/143476855.js"
  fs-consent-categories="marketing"
  fs-consent-scripttype="text/javascript"
></script>

Hi Luis,

Thanks for your answer! Then I think everything is correctly installed now. Thanks for doing some research! :grinning:

1 Like