How to Integrate HubSpot and Google Analytics
Connecting HubSpot to Google Analytics is one of the most powerful things you can do to get a complete picture of your marketing and sales performance. Instead of seeing website traffic in one tab and sales data in another, you can finally connect the dots. This article will show you exactly why this is so important and walk you through how to set it up step-by-step.
Why Connect HubSpot and Google Analytics?
On their own, both Google Analytics and HubSpot are incredibly powerful, but each has a significant blind spot. Google Analytics is fantastic at audience and acquisition analysis, it tells you who is visiting your website, where they came from, and what they do once they arrive. However, its vision ends once a user fills out a form. It doesn't know if that visitor became a qualified lead, started a free trial, or ultimately closed as a high-value customer.
HubSpot, on the other hand, excels at tracking the entire lead lifecycle. It knows everything that happens after someone submits their contact information - every email opened, every sales call logged, and every deal won. Its weakness, however, is in a less detailed view of pre-conversion website behavior and attribution.
By connecting the two, you get the best of both worlds:
- End-to-End Funnel Visibility: See the full customer journey, from the first ad they clicked to their final purchase. You can finally answer questions like, "Which of my blog posts are generating leads that actually turn into customers?"
- Smarter Marketing Attribution: Attribute tangible revenue, not just form submissions, to your marketing campaigns. Knowing that your LinkedIn Ads generated 50 leads is good, but knowing they generated two enterprise deals worth a total of $100,000 is game-changing.
- Aligned Sales and Marketing Teams: When both teams look at the same data, marketing can focus on generating higher-quality leads and sales gets valuable context about a lead’s browsing history and interests before ever picking up the phone.
- Genuine ROI Calculations: Stop guessing the value of your campaigns. By connecting Google Analytics traffic data with HubSpot deal data, you can calculate the true return on investment (ROI) for your marketing spend.
Before You Get Started
First, let’s make sure you have everything you need. This process is straightforward, but you'll have a much easier time if you have these items ready to go:
- Admin Access: You’ll need administrator permissions for both your HubSpot account and your Google Analytics 4 property.
- Tracking Codes: We’ll mainly use Google Tag Manager, but it’s helpful to know your GA4 Measurement ID (it looks like G-XXXXXXXXXX). You can find this in your GA4 admin panel under Data Streams.
- Google Tag Manager: While there are other ways, using Google Tag Manager (GTM) is the most flexible and recommended method. If you don’t have a GTM account set up for your website yet, now is the perfect time to create one.
How to Integrate HubSpot and Google Analytics with Google Tag Manager
The native integration that existed for Universal Analytics is gone, but the GTM method is more powerful anyway. It gives you a central place to manage all your tracking scripts, which keeps your site moving fast and your data clean. Here's how to get it done.
Step 1: Get Your Google Tag Manager Code
Log in to your Google Tag Manager account. If it’s your first time, create an account and a new "container" for your website. Once your container is created, GTM will present you with two snippets of code. If you've already set it up, you can find these codes again by clicking on your GTM ID (e.g., GTM-XXXXXXX) in the top-right corner.
One snippet needs to go in the <head> section of your site, and the other right after the opening <body> tag.
Step 2: Add the GTM Code to Your HubSpot Site
Now, let's place those GTM codes into HubSpot.
- In your HubSpot portal, click the Settings icon (the gear) in the main navigation bar.
- Navigate to Content > Website > Pages in the left sidebar menu.
- Select the domain you want to edit from the drop-down menu (if you have multiple).
- Go to the Integrations tab.
- Check "Integrate with Google Tag Manager" and paste your container ID. HubSpot will place the code for you. Or, for more control: Go to the Templates tab.
- Paste the first
<head>code snippet from GTM into the Site header HTML field. - Paste the second
<body>code snippet from GTM into the Site footer HTML field. While not the technically perfect spot, it works perfectly well in this case. - Click Save to apply your changes.
This simple action has now connected GTM to every page hosted on your HubSpot portal.
Step 3: Deploy the GA4 Tag Through GTM
With GTM installed, you can now add your GA4 tracking tag. This tells GTM to send data to your Google Analytics property.
- Back in your GTM container, go to Tags and click New.
- Name your tag something clear, like "GA4 - Base Configuration".
- Click on Tag Configuration and choose Google Analytics: GA4 Configuration.
- In the Measurement ID field, enter your GA4 Measurement ID (e.g., G-XXXXXXXXXX).
- Next, click on Triggering and select the All Pages trigger.
- Click Save.
- Finally, click the Submit button in the top-right corner of GTM, give your version a descriptive name (like "Installed GA4"), and click Publish.
That's it! Google Analytics is now collecting data for your HubSpot-hosted pages. You can verify it’s working by opening your website and checking the GA4 Realtime report to see if your visit registers.
Advanced Tracking: How to Track HubSpot Form Submissions in GA4
Knowing your page views is great, but an even more valuable step is tracking when someone submits a lead form. This is the crucial event that bridges the gap between marketing activity and sales processes. HubSpot forms can sometimes be tricky to track with standard form submission triggers, so we'll use a reliable and modern technique that listens for a confirmation message from the form.
Step 1: Set Up a Custom Listener for HubSpot Forms
HubSpot’s forms send a little browser message when a submission is successful. We can create a script that "listens" for this message and then tells GTM that a conversion happened.
Add the following code to your HubSpot portal in the same Site footer HTML section where you added your GTM code earlier (Settings > Content > Website > Pages > Templates).
<script type="text/javascript">
window.addEventListener("message", function(event) {
if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
'event': 'hubspot_form_success',
'hubspotFormId': event.data.id
}),
}
}),
</script>This script does one simple thing: when someone successfully submits a form, it pushes a custom event called 'hubspot_form_success' to the data layer that GTM can see.
Step 2: Create a Custom Event Trigger in GTM
Now, let's create a trigger that fires whenever that 'hubspot_form_success' event happens.
- In GTM, go to Triggers and click New.
- Name your trigger something like "Custom Event - HubSpot Form Success".
- For Trigger Configuration, choose Custom Event.
- In the Event Name field, enter hubspot_form_success exactly as it appears in the script.
- Leave it set to "All Custom Events" and click Save.
Step 3: Create the GA4 Event Tag
Finally, we'll create a tag that sends event data to Google Analytics whenever the trigger we just built fires.
- In GTM, go to Tags and click New.
- Name the tag something clear, such as "GA4 - Event - Lead Generated".
- For the Tag Configuration, choose GA4 Event.
- In the Configuration Tag dropdown, select the "GA4 - Base Configuration" tag you made earlier.
- In the Event Name field, use generate_lead.
- Click on Triggering and select the "Custom Event - HubSpot Form Success" trigger.
- Click Save.
Step 4: Test and Publish
Always test your changes before publishing. GTM's Preview mode is perfect for this.
- Click the Preview button in GTM and enter your website URL.
- Your site will open in a new tab with a debug panel.
- Navigate to a page with a HubSpot form and fill it out with test information.
- After a successful submission, watch the debugger. You should see hubspot_form_success appear in the list.
- Click on it, and you'll see that your tag, "GA4 - Event - Lead Generated," has successfully fired.
If everything looks good, go back to GTM and click Submit and then Publish to push your changes live. As a final step, go to your GA4 Admin panel under Conversions and mark generate_lead as a conversion event. This will make it easier to see in your key reports and measure campaign performance.
Final Thoughts
Connecting your marketing analytics with your CRM is no longer an optional step - it's essential for smart, data-driven growth. Following these steps gives you a seamless way to track performance from first touch to final sale, empowering you to make better marketing decisions and prove the value of your efforts.
Of course, integrating your data is just the beginning. The real challenge is translating that mountain of data into actionable insights without spending half your week building reports. At Graphed, we handle that automatically. After connecting your sources like Google Analytics and HubSpot, you can simply ask questions in plain English, like "Show me a chart of blog posts that generated the most revenue from closed deals last quarter,” and get a live dashboard in seconds. It allows you to skip straight to the insights and focus on making smart decisions, not wrangling spreadsheets.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?