How to Add Google Tag Manager Code in Hubspot
Connecting Google Tag Manager to your Hubspot content lets you manage marketing tags centrally while keeping your site fast and organized. This guide walks through the exact steps to install the container code in Hubspot pages, blog templates, and individual content items.
What You Need Before Setting Up Google Tag Manager in Hubspot
Before you add the tracking code to Hubspot, make sure you have the following ready:
- A published Google Tag Manager container
- Access to your Hubspot account with permission to edit settings and website content
- The Google Tag Manager code snippet (both script and noscript parts)
If you have not created a container yet, sign in to your Google Tag Manager account and create one for your domain. Then copy the default installation code that Google provides.
Where to Place Google Tag Manager Code in Hubspot
Google Tag Manager uses two parts of code:
- A script that must be placed in the
<head>section of your site - A noscript iframe that should appear immediately after the opening
<body>tag
Hubspot lets you add these code snippets globally for all pages, or per page or blog post. Choosing the right method depends on whether you want to track every piece of content or only selected items.
Add Google Tag Manager to All Hubspot Pages
Use this method when you want every Hubspot page and blog post to send data through Google Tag Manager.
Step 1: Copy Your Google Tag Manager Snippets
- Open your Google Tag Manager account.
- Select your container.
- Click the installation instructions to display the code.
- Copy both the
<head>script and the<body>noscript code.
Step 2: Add the Head Code in Hubspot Site Settings
- Sign in to your Hubspot account.
- In the main navigation, go to Settings.
- In the left sidebar menu, navigate to Website > Pages.
- Locate the section for site-wide header HTML.
- Paste the Google Tag Manager
<head>code into the header field. - Save your changes.
This adds the container script to every page managed by your Hubspot content tools, including website pages and blog posts that use standard templates.
Step 3: Insert the Body Code in Hubspot Templates
Hubspot themes and templates control where the opening <body> tag appears. To correctly place the noscript part of Google Tag Manager, you need to edit your theme or layout in the design tools.
- Go to Marketing > Files and Templates > Design Tools in Hubspot.
- Open the theme or template used by your website pages.
- Locate the main layout file that defines the
<body>element. - Immediately after the opening
<body>tag, paste the Google Tag Manager noscript iframe code. - Save and publish changes to the template.
Once published, every Hubspot page using that template will automatically load the full container code in the recommended locations.
Add Google Tag Manager to Specific Hubspot Pages Only
Sometimes you may not want Google Tag Manager on every Hubspot page, for example on internal tools or limited-access content. In that case you can add the script on a page-by-page basis.
Step 1: Add the Page-Level Head Code
- In Hubspot, open Marketing > Website > Website Pages or Landing Pages.
- Hover over the page you want to track and click Edit.
- In the page editor, open the Settings or Advanced options panel.
- Look for the page-level Header HTML or Head HTML field.
- Paste the Google Tag Manager
<head>script into this field. - Update or publish the page.
This places the container script only on the selected Hubspot page without affecting your entire site.
Step 2: Add the Body Code Using a Custom Module or Template Edit
Hubspot page editors do not always expose the exact location of the opening <body> tag. To position the noscript code correctly, use one of these approaches:
- Create a small custom HTML module that contains only the noscript iframe and insert it at the top of the layout region that appears first on the page.
- Edit the underlying theme or template used by only that specific page type and paste the noscript snippet just under the
<body>tag.
After saving the modifications, republish the page to activate the change.
Adding Google Tag Manager to Hubspot Blog Templates
If you run a blog through Hubspot, you can ensure every post includes the tracking container by updating the blog template settings.
Step 1: Confirm Your Blog Uses a Single Template
In Hubspot settings, open your blog configuration and check which template is assigned to blog posts and the listing page. If multiple templates are in use, repeat the next step for each one you want to track.
Step 2: Edit the Blog Template for Google Tag Manager
- Navigate to Files and Templates > Design Tools in Hubspot.
- Open the blog post template file.
- Paste the
<head>script into the global header section if it is not already inherited from your main site layout. - Place the noscript iframe code right after the opening
<body>tag within the blog layout. - Save and publish the template.
Now all new and existing blog posts that use that template will load Google Tag Manager automatically.
How to Verify Google Tag Manager is Working on Hubspot Pages
After installing the container code on your Hubspot site, always test to confirm it loads correctly before relying on the data.
- Install the Google Tag Assistant or use the Tag Manager preview mode.
- Open the Hubspot page or blog post in a new incognito or private window.
- Check that the container ID appears and that tags fire as expected.
- Verify that no duplicate containers are loaded from other integrations or legacy scripts.
If the container does not appear, recheck that the script is placed in the header and that your template changes are published in Hubspot.
Troubleshooting Google Tag Manager in Hubspot
If tracking does not work as expected, common issues in Hubspot setups include:
- Multiple installations – The container code may exist both in global header settings and inside a template, causing duplicates.
- Template caching – Recent template changes in Hubspot might not be reflected if the page was not republished.
- Conflicting scripts – Other analytics tools hardcoded into templates can interfere with certain tags.
To resolve problems, compare your implementation with the official instructions from the Hubspot knowledge base at this page on adding Google Tag Manager code to Hubspot content. Confirm that your container code matches the latest version from your Google Tag Manager account.
Best Practices for Managing Tags on Hubspot Sites
Once Google Tag Manager is live on your Hubspot assets, follow best practices to keep your implementation clean and reliable:
- Use one primary container per Hubspot domain.
- Group tags logically (analytics, advertising, UX tools) and name them clearly.
- Rely on triggers based on Hubspot page URLs, paths, or custom events to scope tags correctly.
- Document which templates and sections of your Hubspot site include special tracking requirements.
For more advanced tag configurations or to audit your current tracking setup, you can work with analytics and marketing operations specialists. A consulting partner such as Consultevo can help review your Hubspot templates, clean up scripts, and design a scalable tracking architecture.
Summary: Keep Google Tag Manager and Hubspot in Sync
By adding the Google Tag Manager code to global headers, templates, or specific pages, you can centralize tag management across all your Hubspot content. Always place the script in the head section, the noscript code right after the body tag, test with preview tools, and avoid duplicate containers. With a careful setup, you gain accurate analytics and the flexibility to adjust marketing tags without constantly editing Hubspot page code.
Need Help With Hubspot?
If you want expert help building, automating, or scaling your Hubspot , work with ConsultEvo, a team who has a decade of Hubspot experience.
“`
