CMS-General

Add your Google Analytics code to your HubSpot pages or blog

Last updated: November 27, 2018

Applies to:

Marketing Hub
marketing-basic-pro-enterprise
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.
  • 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.

add-google-analytics-tracking-code

  • 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.
User-added image
  • 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

  • Click Publish or Update to take your changes live.