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).
To add code to the head or footer HTML of a specific page:
- Navigate in HubSpot Marketing 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).
- Scroll down to the Advanced Options section and click Add Head HTML or Add Footer HTML.
- Add your code snippet to the raw HTML editor. Click Save.
- Click Update to take your changes live.
To add code to the head or footer HTML of all of your pages at the domain-level:
- Navigate in HubSpot Marketing to Content > Content Settings.
- Choose the domain you'd like to edit from the Select a domain to edit dropdown. If you'd like your code to apply to all pages on all of your domains, choose Default for All Domains.
- Please note: You can also 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 for a specific domain, it will override any code you have placed in Header and Footer under all domains.
- Scroll down to the Site Header HTML and Site Footer HTML fields.
- Add your code snippet to the appropriate section. Scroll down and click Save Changes.
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). If you're looking to add your Google Analytics code to your HubSpot pages, please check out these instructions.