Integrating GA4 and GTM with HubSpot
Connect Google Analytics 4 to HubSpot
You can apply GA4 tracking to a single domain or all HubSpot-hosted domains. Domain-specific settings always take priority over default settings.
- In HubSpot, click the Settings icon in the top navigation bar.
- In the left sidebar, go to Content > Pages.
- Click the Choose a domain dropdown and select a domain — or choose Default settings for all domains to apply tracking site-wide.
- Click the Integrations tab.
- Under Tracking integrations, check Integrate with Google Analytics 4.
- Enter your GA4 Measurement ID in the field provided.
- Click Save.
To disconnect GA4, uncheck the same checkbox and save.
Connect Google Tag Manager to HubSpot
Once connected, GTM runs across all HubSpot-hosted content. Content hosted outside HubSpot must be connected to GTM separately.
- In HubSpot, click the Settings icon in the top navigation bar.
- In the left sidebar, go to Content > Pages.
- Click the Integrations tab.
- Check Integrate with Google Tag Manager.
- Enter your GTM Container ID (e.g.
GTM-XXXXXXX). - Click Save.
Add GTM Code Manually (Domain-Specific)
Use this if you only want GTM on specific domains rather than all HubSpot-hosted content. Requires access to your domain's header/footer HTML settings.
Step 1 — Copy your GTM snippets:
- Log in to Google Tag Manager.
- Click the Admin tab.
- Click the Container dropdown and select your container.
- Click Install Google Tag Manager.
- Copy both code snippets — (1) goes in the
<head>, (2) goes immediately after the opening<body>tag.
Step 2 — Add snippets to HubSpot:
- In HubSpot, go to Settings > Content > Pages.
- Select the domain you want to track.
- Paste snippet (1) into the Head HTML field and snippet (2) into the Footer HTML field.
- Click Save.