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

Last updated: April 26, 2017

Available For:

Marketing: Basic, Pro, Enterprise
Sales: N/A

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 in the bottom left corner > select the desired domain to track under the Property dropdown > click on Tracking Code.
User-added image
  • On the following page, copy your Tracking ID.
User-added image

After you have obtained your Google Analytics Tracking ID, return to HubSpot. 


To apply your Google Analytics tracking code to all pages on all domains or all pages on a specific domain:

  • Navigate in HubSpot Marketing to Content > Content Settings.
  • Under Select a Domain to Edit, you can either select Default for All Domains to apply the Google Analytics code to all pages or select a particular domain so the code only applies to HubSpot pages using that domain.
User-added image
User-added image
  • Scroll down to Google Analytics, and check off the box to Integrate with Google Analytics.
  • Next, paste your Google Analytics Tracking ID.
User-added image
After inserting the Tracking ID, scroll down and click on Save Changes.

In some instances, users have customized Google Analytics codes for other purposes. In the case 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.

  • Locate the Site Header HTML code box > paste the Google Analytics code into the box > scroll down and click the Save changes button to finish.
User-added image

To apply your Google Analytics code only to a specific blog:

Please note: if you've applied your code to all domains or your specific blog domain using the instructions above, your code will be applied to your blogs automatically. Only follow these instructions if you want your code to be applied only to a particular one of your blogs. 
  • Navigate to Content Content Settings.
  • Select Blog from the left-hand menu. 
  • Choose the blog to which you'd like to apply the Google Analytics tracking code from the Select a blog to modify dropdown.

  • 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, check the Use same header HTML for blog posts box or, if you use different code snippets for your listing pages and blog posts, paste the Google Analytics tracking code into the Header HTML for Blog Posts box. 

  • Scroll down and click the Save changes button. 


To apply Google Analytics only to a particular page:

  • Content > Landing Pages or Website Pages, locate the page in question and access it for editing.
  • Under the Settings tab, paste the Tracking Code (not the Tracking ID) in the Head Section HTML section under Advanced Options. When ready, click on Publish/Update Page button to finish.
User-added image

Was this article helpful?