You can integrate your HubSpot website and blog content with Google Analytics by adding your Google Analytics tracking ID in your HubSpot settings.
If your developers have customized your Google Analytics script, 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.
When you integrate Google Analytics with HubSpot, your Google Analytics account will collect data on the visitors to your HubSpot site.
Please note: as of November 1, 2019, if you have GDPR settings enabled or have a cookie policy banner that requires visitor opt-in, HubSpot will only run the Google Analytics script if your visitors opt in to being tracked. If a visitor opts out, the Google Analytics script will not run and the visitor's data won't be tracked.
To integrate Google Analytics with all HubSpot domains or a specific HubSpot domain:
Please note: if you integrate Google Analytics with a specific HubSpot domain, it will override any integration preferences you set as the default settings for all domains.
If your developers have customized your Google Analytics script, to maintain the changes they've made to the code, do not integrate Google Analytics with HubSpot using the tracking ID. Copy your custom Google Analytics tracking code and add it to the the Site header HTML code editor in your settings.
Please note: when you add your Google Analytics tracking code to the header HTML instead of integrating Google Analytics with HubSpot, the Google Analytics script cannot be controlled by the HubSpot cookie policy banner and by default, will record data on visitors regardless of whether a visitor opts in or out, unless you customize your Google Analytics script.
Your legal and developer teams are the best resources to help you ensure that your use of the Google Analytics script on your site is compliant with privacy laws. This Google document on disabling the Google Analytics tag may be a helpful resource for your developer team.
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.
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.
This feature is only available in Marketing Hub Professional and Enterprise and CMS Hub Professional and Enterprise accounts.