Add your Google Analytics code to your HubSpot pages or blog
Last updated: June 26, 2020
You can integrate your HubSpot website and blog content with Google Analytics by adding your Google Analytics tracking ID in your HubSpot settings. If you have a customized Google Analytics account, or if you only want to add Google Analytics tracking to a specific page or blog, add your Google Analytics tracking code snippet to the site header HTML for your pages or blog.
- Apply Google Analytics tracking code to all pages on all domains or all pages on a specific domain
- Apply customized Google Analytics tracking code to all pages on all domains or all pages on a specific domain
- Apply Google Analytics only to a particular page
Apply your Google Analytics tracking code to all pages on all domains or all pages on a specific domain
- In your HubSpot account, click the settings icon settings in the main navigation bar.
- In the left sidebar menu, navigate to Website > Pages.
- Use the Modifying dropdown menu to choose the domain where you'd to add the code. Select All domains to add the code to all of your HubSpot-hosted domains.
- Click the Tracking tab, then click the Integrate with Google Analytics checkbox.
- Paste your Google Analytics tracking ID in the text field.
- Scroll down to Tracking Integrations, and select the Integrate with Google Analytics checkbox.
- Enter your Google Analytics tracking ID.
- Click Save to apply your changes.
Apply customized Google Analytics tracking code to all pages on all domains or all pages on a specific domain
If you have a customized Google Analytics account, don't use the tracking ID. Instead, copy your Google Analytics tracking code snippet and add it to the the Site header HTML code editor in your settings.
- In your HubSpot account, click the settings icon settings in the main navigation bar.
- In the left sidebar menu, navigate to Website > Pages.
- Use the Modifying dropdown menu to choose the domain where you'd to add the code. Select All domains to add the code to all of your HubSpot-hosted domains.
- Click the Templates tab.
- Paste your Google Analytics tracking code snippet into the Site Header HTML code editor.

- Click Save to apply your changes.
Please note: if you add code to the header or footer HTML for a specific domain, it will override any code you've placed in your header and footer HTML for All domains.
Apply your Google Analytics code to a specific blog
If you've applied your code to all domains using the instructions above, your code will be applied to all your HubSpot blogs automatically. Only follow these instructions if you want your code to be applied to a specific blog and not your other HubSpot content.
- In your HubSpot account, click the settings icon settings in the main navigation bar.
- In the sidebar menu, navigate to Website > Blog.
- Use the Select a blog to modify dropdown menu to choose the blog you'd like to track with Google Analytics.
- Click the Templates tab, and scroll down to the Header HTML for Blog Listing Pages field and paste your Google Analytics tracking code snippet into the code editor.
- To apply the code to your blog posts as well, select the Use the same header HTML for blog posts checkbox.
- Click Save to apply your changes.
Apply Google Analytics only to a particular page
- In your HubSpot account, navigate to your landing pages or website pages.
- Hover over the page you want to update and click Edit.
- Click the Settings tab at the top of the page editor.
- Click Advanced Options and scroll down to the Advanced Code Snippets section and paste your Google Analytics tracking code snippet in the Head HTML code editor.
- Click Publish or Update to take your changes live.