CMS-General

Add your Google Analytics code to your HubSpot pages or blog

Last updated: March 22, 2019

Applies to:

Marketing Hub  Professional, Enterprise
Legacy Marketing Hub Basic
HubSpot CMS

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 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 WebsitePages.
  • Click the Choose a domain to edit dropdown menu and select the domain to add the code to. To add the code to all your HubSpot-hosted domains, select All domains.
  • Click the Integrations tab, then select the Integrate with Google Analytics checkbox.
  • In the text field, enter your Google Analytics tracking ID.

  • In the bottom left, click Save.

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, do not use the tracking ID. Copy your custom Google Analytics tracking code snippet and add it to the the Site header HTML code editor in your settings. To do this:

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Website Pages.
  • Click the Choose a domain to edit dropdown menu and select the domain to add the code. To add the code to all your HubSpot-hosted domains, select All domains.
  • In the bottom left, click Save.

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 left sidebar menu, navigate to Website Blog.
  • Click the Select a blog to modify dropdown menu and select the blog you want to track with Google Analytics.
  • Click the Templates tab, and in the Header HTML for Blog Listing Pages field, enter your Google Analytics tracking code snippet
  • 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

  • Click Publish or Update to take your changes live.