CMS-General

How do I put my Google Analytics code onto my HubSpot pages?

Last updated: October 19, 2018

Applies to:

Marketing Hub
marketing-basic-pro-enterprise
Basic, Professional, Enterprise

Please follow the directions noted below to integrate Google Analytics with your HubSpot Marketing account. Following the steps below will add your Google Analytics code to your HubSpot pages.

First, you will need to obtain your Google Analytics Tracking ID:

  • Log into your Google Analytics account.
  • Click the admin gear icon.
  • Choose the desired domain to track under the Property dropdown, then click Tracking Code.
User-added image
  • On the following page, copy your Tracking ID. You'll use this ID to connect Google Analytics to your HubSpot account.

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 sidebar menu, navigate to WebsitePages.
  • Use the Modifying dropdown menu to choose the domain where you'd to add the code. You can also choose 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 check off the box to Integrate with Google Analytics.
  • Next, paste your Google Analytics tracking ID.

add-google-analytics-tracking-code

If you have a customized Google Analytics account, do not use the Tracking ID. Simply copy your Google Analytics Tracking Code instead and insert it in the the Site header HTML section.

  • On your Page settings, click the Templates tab.
  • Paste the Google Analytics code into the Site Header HTML code box
  • Click Save to apply your changes.
User-added image

Please note: if you do add any code within the header or footer HTML for a specific domain, it will override any code you have placed in header and footer HTML for All domains.

Apply your Google Analytics code to a specific blog

Please note: 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 the rest of your 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 your Google Analytics tracking code.

  • Click the Templates tab, and scroll down to the Header HTML for Blog Listing Pages field and paste your Google Analytics tracking code into the box. 
  • To apply the code to your blog posts as well, click the Use the same header HTML for blog posts checkbox. To apply separate tracking code for your blog posts only, uncheck the Use the same header HTML for blog posts checkbox.

  • Click Save to apply your changes. 

To apply Google Analytics only to a particular page:

  • In your HubSpot account, navigate to Landing Pages or Website Pages, then locate the page in question and click the name to edit it.
  • Click Advanced Options and scroll down to the Advanced Code Snippets section and enter your code you in the Head HTML editor.
User-added image
  • Click Save, then Publish to take your changes live.

Was this article helpful?

If you still need help you can get answers from the , or to contact support.