Add code to the head or footer HTML of your pages

Last updated: September 20, 2019

Applies to:

Marketing Hub  Professional, Enterprise
Legacy Marketing Hub Basic
HubSpot CMS

You may want to add snippets of code to the head or footer HTML of your pages for custom styling or tracking purposes. HubSpot allows you to add these custom HTML snippets, conversion or transaction tags, embed codes, and/or JavaScript tracking codes on specific pages or sitewide. Your code will be added within the head section and/or directly before the closing body tag of your page(s).

Please note: if you are embedding code from an external source, review the embed instructions to determine where the code should be added to your page HubSpot (header, footer, or in the body of your page). Learn how to add your Google Analytics code.

Add code to the head or footer HTML of a specific page

  • In your HubSpot account, navigate to your landing pages or website pages.
  • Hover over the page and click Edit
  • In the page editor, click the Settings tab. 
  • Click Advanced Options to open the Advanced Code Snippets section and enter your code into the Head HTML or Footer HTML field.


  • Click Update to apply your changes.

Add code to the head or footer HTML of all pages hosted on a specific domain

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Website > Pages.
  • Click the dropdown menu to select the domain you want to update settings for. 
  • Make updates to the default HTML applied to templates for the selected domains:
    1. Site header HTML 
    2. Site footer HTML

  • Click Save to apply your changes.