- Knowledge Base
- Content
- Website & Landing Pages
- Use code snippets with HubSpot content
Use code snippets with HubSpot content
Last updated: February 11, 2026
Available with any of the following subscriptions, except where noted:
Code snippets allow custom scripts or markup to be added to HubSpot-hosted content. Common use cases include analytics tracking, third-party integrations, and custom functionality that must load in the head or footer of a page.
Before you get started
Before using code snippets with HubSpot content, review the requirements and considerations.
Permissions required The following permissions are required:
- Edit and Publish permission is required to add code snippets to specific pages, posts, or articles.
- Website settings permission is required to add code snippets to all content hosted on a specific domain.
Understand limitations & considerations
-
Code snippets can be added at two levels:
- To a specific page, blog post, or knowledge base article.
- To all HubSpot-hosted content on a specific domain.
- Review the embed instructions for any external code snippets to confirm whether they should be added to the head, body, or footer HTML of your content.
- Editing options for head and footer HTML vary by subscription and content type.
- Header or footer HTML configured for all domains, or for a domain used for quotes, will appear on quotes as well as website content.
Add code snippets to specific content
Use this method when code snippets should apply only to an individual page, blog post, or knowledge base article.
-
Navigate to your content:
- Website Pages: In your HubSpot account, navigate to Content > Website Pages.
- Landing Pages: In your HubSpot account, navigate to Content > Landing Pages.
- Blog: In your HubSpot account, navigate to Content > Blog.
- Knowledge Base: In your HubSpot account, navigate to Service > Knowledge Base.
- Click the name of your content.
- In the content editor, click the Settings menu and select Advanced.
- In the Additional code snippets section of the dialog box, enter your code snippet into the Head HTML or Footer HTML field.
- When finished, click Publish or Update to take your changes live.
Please note: the footer HTML field is not available for blog posts or knowledge base articles.
Add code snippets to all content hosted on a specific domain
Use this method when code should apply across all HubSpot-hosted content on a domain, such as site-wide tracking scripts.
- In your HubSpot account, click the settings settings icon in the top navigation bar.
- In the left sidebar menu, navigate to Content > Pages.
- Click the Choose a domain to edit its settings dropdown menu and select a domain. To apply the same code to all HubSpot-hosted content, select Default settings for all domains.
- To edit the header or footer for a specific domain, click Override default settings in the Site Header HTML or Site Footer HTML section. Code added to the default settings will no longer apply to this domain's content.
- To revert a specific domain's header or footer HTML to the Default settings for all domains instead, click Apply default settings.
- Enter your code snippets.
- In the bottom left, click Save to apply your changes.