HubSpot Cookie Banner: How to Add a Cookie Banner on HubSpot with iubenda

Once you’ve added a privacy policy to your HubSpot site (which also includes the cookie policy if you’ve activated it), you can complete the setup by embedding Privacy Controls and Cookie Solution. This lets you display a fully customizable cookie banner, collect cookie consent, and implement prior blocking as required by the ePrivacy Directive, GDPR, and other privacy regulations.

The integration on HubSpot works by creating a JavaScript file in HubSpot’s Design Tools, then attaching it to your site template so it loads on every page.

What the solution supports

When you embed the Privacy Controls and Cookie Solution on your HubSpot site, you get access to the full feature set of the iubenda cookie management platform:

How to add a cookie banner to your HubSpot site

Step 1: Copy the embed code from iubenda

Go to your iubenda Dashboard and click on [Your website] > Privacy Controls and Cookie Solution > Embed

iubenda dashboard showing Privacy Controls and Cookie Solution

Copy the embed code snippet from the embedding section.

Privacy Controls and Cookie Solution embed code snippet

Keep this code handy. You’ll paste it into a JavaScript file in the next step.

Step 2: Create a JavaScript file in HubSpot Design Tools

  1. In your HubSpot account, go to Marketing > Design Tools.
HubSpot Marketing menu showing Design Tools option
  1. In the sidebar, click File > New file. (You may need to click the folder icon first.)
  2. Select JavaScript from the “What would you like to build today?” dropdown, then click Next.
Creating a new JavaScript file in HubSpot Design Tools
  1. Enter a name for your script in the File name field (e.g. “iubenda-cookie-solution”).
  2. Click Change in the File location section and choose a folder.
  3. Click Create.
HubSpot new file creation dialog with file name and location fields

Step 3: Paste the iubenda code into the JavaScript file

  1. Paste the Privacy Controls and Cookie Solution embed code (copied in Step 1) into the editor.
  2. If ESLint shows warnings or errors, use the Show output toggle to review them. These warnings typically do not prevent the code from working.
  3. Click Publish changes in the top right.
HubSpot code editor with iubenda script pasted and Publish changes button

Step 4: Attach the script to your site template

  1. In the Design Tools sidebar, find the template you want to update.
  2. In the inspector on the right, click the Edit tab.
  3. Under Linked JavaScript files, click Add and select the iubenda script you just created.
  4. Click Publish changes.
Adding a linked JavaScript file to a HubSpot template

Repeat this for each template that your pages use, so the cookie banner appears across your entire site.

Step 5: Include the Privacy Controls and Cookie Solution script on your HubSpot pages

You can add the script to all pages on a domain at once, or to individual pages. Choose the method that works best for your setup.

Option A: Add the script to all pages on a domain

  1. In the Design Tools sidebar, right-click your script file and choose Actions > Copy public URL.
  2. Go to Settings (the gear icon in the main navigation bar).
  3. Navigate to Website > Pages in the left sidebar.
  4. Use the dropdown to select a specific domain, or apply the script to all domains.
  5. In the Site footer HTML field, paste the following code (replacing the placeholder with your public URL):
<!-- start iubendaCookieSolution.js -->
<script src="YOUR_FILE_PUBLIC_URL_HERE"></script>
<!-- end iubendaCookieSolution.js -->
  1. Click Save.

Option B: Add the script to an individual page

  1. Go to Marketing > Website > Website Pages (or Landing Pages). Hover over the page you want to edit and click Edit.
  2. Click the Settings tab, then expand Advanced options.
  3. In the Footer HTML field, paste the following code (replacing the placeholder with your public URL):
<!-- start iubendaCookieSolution.js -->
<script src="YOUR_FILE_PUBLIC_URL_HERE"></script>
<!-- end iubendaCookieSolution.js -->
  1. Click Update in the top right to apply your changes.

Set up prior blocking of cookie scripts

Few categories of cookies are exempt from the consent requirement. Therefore, almost all scripts that install or can install cookies must be blocked before consent is obtained.

Simplify your cookie-blocking process with auto-blocking

There’s a simpler option available for the prior blocking of cookies and trackers. Our auto-blocking feature automates the process, saving you time and effort.

If you prefer to manually tag your scripts, see our guide on blocking via manual tagging or explore other methods in our general introduction to the prior blocking of cookies.

Using Google Tag Manager with HubSpot

If you manage third-party scripts through Google Tag Manager (GTM), you can use iubenda’s GTM template for more granular control over consent-based script firing. This approach works well for HubSpot sites with complex tracking setups.

Good to know: HubSpot-specific considerations

Keep these points in mind when using Privacy Controls and Cookie Solution on HubSpot:

  • JavaScript file vs. code injection. The recommended method for HubSpot is to create a dedicated JavaScript file in Design Tools rather than pasting the code directly into the site footer HTML. The JS file approach keeps your code organized and makes it easier to update. However, if you only need the banner on a few pages, using the footer HTML method (Step 5, Option B) is a simpler alternative.
  • Google Tag Manager integration. If you already use GTM on your HubSpot site, you can load the iubenda snippet through GTM instead. This gives you centralized control over all your tags and works well with Google Consent Mode.
  • Auto-blocking coverage. Auto-blocking works at the JavaScript level and handles most third-party scripts. For scripts not automatically detected, use the manual tagging method or route scripts through Google Tag Manager for more control.

Manage cookie consent for your HubSpot site

Generate a cookie banner

See also