Add code to the head or footer HTML of your pages

Last updated: June 21, 2018

Applies to:

Marketing Hub: Basic, Pro, Enterprise

Sometimes, 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 Javacript 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).

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

  • In your HubSpot Marketing account, navigate to Content > Landing Pages or Website Pages.
  • Find the page you'd like to edit. Click the gear icon to the right, then choose Edit
  • Within the page editor, click the Settings tab (top-center). 
  • Click Advanced Options and scroll down to the Advanced Code Snippets section and enter your code into the Head HTML or Footer HTML field. Click Save.


  • Click Update to take your changes live. 

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.
  • On the left, click MarketingWeb pages.
  • In the Modifying dropdown at the top, select the specific domain you'd to add the code to, or select All domains to add the code to all of your HubSpot-hosted domains.

Please note: you can choose specific domains if you want to add code to one domain but not another you have in HubSpot. If you do add any code within the header or footer HTML for a specific domain, it will override any code you have placed in header and footer HTML for All domains.

  • Enter your code into the Site header HTML or Site footer HTML section.

  • Click Save at the bottom left.

Please note: if you are embedding code from an external source, review the embed instructions to determine where the code should be added within HubSpot (head, footer, or within the content body of your page). You can learn how to add your Google Analytics code to your HubSpot pages here.

Was this article helpful?

If you still need help you can get answers from the , or to contact support.