Add the Google Tag Manager code to HubSpot content
Last updated: June 15, 2022
Applies to:
All products and plans |
You can integrate Google Tag Manager with HubSpot to track your HubSpot-hosted landing pages, website pages, blog, and knowledge base in Google Tag Manager. Learn more about Google Tag Manager in Google's getting started guide, which includes a page on common questions.
Integrate with Google Tag Manager
When you integrate HubSpot with Google Tag Manager, the tag manager will run on all HubSpot-hosted content. External content will need to be connected separately to Google Tag Manager.
- In your HubSpot account, click the settings settings icon in the main navigation bar.
- In the left sidebar menu, navigate to Website > Pages.
- Click the Integrations tab.
- Select the Integrate with Google Tag Manager checkbox.
- Enter your Google Tag Manager ID in the text field. Learn how to find this in your Google Tag Manager account.
- Click Save to apply your changes.
Add the Google Tag Manager code manually
You can also add the Google Tag Manager code to HubSpot-hosted content manually. This is recommended if you only want some HubSpot-hosted domains tracked this way. These steps only apply for accounts that have access to site header and footer HTML settings.
Copy the code from Google Tag Manager
- Log into your Google Tag Manager account.
- Click the Admin tab.
- Click the Container dropdown and select the Container that contains your tags.
- Click Install Google Tag Manager.

- On the next screen, you will be able to copy both code snippets (1) and (2) for your Google Tag Manager Container.

Add the Google Tag Manager code to HubSpot content
- In your HubSpot account, click the settings settings icon in the main navigation bar.
- In the left sidebar menu, navigate to Website > Pages.
- Click the Choose a domain to edit its settings dropdown menu and select a domain. If you want to add the code to all your HubSpot-hosted domains, select Default settings for all domains.

Please note: if you add code to the header or footer HTML for a specific domain, it will override any code you have placed in header and footer HTML in Default settings for all domains. Learn more about the order that code is applied to your pages.
- Paste the code snippets copied from Google Tag Manager:
- Add the Javascript code snippet in the Site header HTML field.
- Add the <noscript> code snippet to the Site footer HTML section.

- Click Save to apply your changes.
Thank you for your feedback, it means a lot to us.
Related content
-
Integrate Google Analytics with HubSpot content
When you integrate Google Analytics with HubSpot, your Google Analytics account will collect data on the...
Knowledge Base -
Require member registration to access private content
Users with publish permissions can control which contacts can access specific HubSpot-hosted pages, blogs and...
Knowledge Base -
Create and customize pages
In HubSpot, you can create website and landing pages for your website. You can customize page content and...
Knowledge Base