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

Last updated: February 13, 2018

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:

  • In your HubSpot Marketing BasicProfessional, or Enterprise account, navigate to Content Content Settings.
  • In the Modifying dropdown at the top, select the specific domain you'd to add the code to, or select All domains to add the code to all of your HubSpot-hosted domains.

Please note: you can choose specific domains if you want to add code to one domain but not another you have in HubSpot. 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.

  • Scroll down to Tracking Integrations, 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.

  • Scroll down tp the Site Header HTML code box and paste the Google Analytics code into the box.Click the Save 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 MarketingBlog from the left sidebar menu.
  • Choose the blog to which you'd like to apply the Google Analytics tracking code from the Select a blog to modify dropdown.

  • 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, check the Use the same header HTML for blog posts box. If you use different code snippets for your listing pages and blog posts, leave the Use the same header HTML for blog posts box unchecked, and paste the Google Analytics tracking code into the editor below labeled Blog post header HTML

  • Click the Save button. 

To apply Google Analytics only to a particular page:

  • Navigate to Content > 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?