CRM Technology

Connecting HubSpot & Google Analytics

  ●   October 14, 2021 | Analytics, Technology
Written by
October 14, 2021 | Analytics, Technology

Independently, Google Analytics and HubSpot can provide rich data insights about your website, CRM and inbound marketing performance. In this article, we explore how to connect these two powerful platforms to unlock even more value.

We will cover:

  • Why you might want to to use Hubspot data in Google Analytics
  • The top level process for how to do this
  • Common challenges you may encounter

Why connect Google Analytics & HubSpot?

HubSpot contains a wealth of valuable information about your clients and prospects, such as their purchase history and lead quality. However, by default none of this information is visible within Google Analytics.

By default your digital teams are unable to access this valuable data within Google Analytics and, therefore, cannot optimise marketing strategies using it. Subsequently, this can lead to KPI Myopia and a whole range of less than pleasant results.

By importing key business metrics within HubSpot into Google Analytics you can avoid KPI Myopia and achieve the following benefits:

  • Identify top performing sections of your website;
  • Improve the quality of leads generated from your digital activity;
  • Improve the profitability of your business or marketing channel;
  • Better demonstrate the value of your digital marketing to clients and bosses.

How to connect HubSpot with Google Analytics

Capturing the Google Client ID

The first step in completing a HubSpot to Google Analytics connection is to capture the Google Analytics Client ID (or CID) across all forms present on your site.

The CID is a unique ID generated by Google Analytics, and will be used as the primary key to join user behaviours tracked in HubSpot with those tracked in Google Analytics. 

The exact steps to take here will change depending on if you are using HubSpot forms or not. 

  • Extract the client_id from the google analytics tag at page load
    • There are two main ways to read this ID:
      • Reading the “_ga” cookie
      • Accessing the GA tracker on site
  • Store the CID in a hidden form field
  • Pass this hidden form field to HubSpot at form submission and store it at contact level in HubSpot.

Export your HubSpot data

Once CID has been stored at contact level, you can now export the CRM data and prepare it for upload from HubSpot to Google Analytics. Data should be exported daily (either via manual exports or the HubSpot API).

You should export the CID column along with metric columns you wish to track in Google Analytics. Common metrics to share include customer lifetime value, deal value and lead stage. 

The data should be exported at contact level. It is possible to export at other levels (for example deal or company), however, this brings additional complications. Additional logic within HubSpot would need to be set up to map contacts to companies.

Once data has been exported it can now be sent to GA via Measurement Protocol.

Create your Measurement Protocol hit structure

Measurement Protocol is an API Google maintains to allow developers to send events to Google Analytics directly. 

To set this up, liaise with your Analytics team and decide on an event structure that is compatible with your own GA property. The reference documentation can be found here.

Ideas include using “event_value” and “event_category” fields to send revenue updates and “event_action” and “event_category” fields to send lead status updates. Goals can then be set up based on these events for KPI reporting or for optimising paid campaigns via Google Ads

We also recommend passing the date of revenue or lead generation to be submitted in the event label or as a custom dimension. 

The dates for when the revenue and other metrics are sent to GA are not guaranteed to match the date they occurred in HubSpot – importantly these dates probably are different to the dates for when the deal/leads were generated, or the date your business considers revenue to have been generated or deals to have been closed. 

Send Measurement Protocol hits to Google Analytics

Once you have decided on an event structure, you can then send these events to Google Analytics.

Hits can be sent to Google Analytics using the Google Analytics Hit Builder, although doing this daily for more than a handful of hits quickly becomes inefficient. To help overcome this challenge, Semetrical built SAM technology to manage our Measurement Protocol hits at scale. 

If you want to develop your own solution, I would suggest writing a Python/Google App Script/VBA script.
Broadly the steps look like this:

  • Ingest HubSpot contacts from a csv or DB
  • Remove invalid characters (float values and dates can be troublesome)
  • Transform rows into Measurement Protocol hit strings
  • Send these hit strings in batches to the Measurement Protocol endpoint

Common challenges you will encounter

Now let’s talk through some of the challenges you will face when you try to do this for real. The integration seems simple on the surface, but in reality it is anything but. We have had to develop solutions to all these problems when building SAM, our GA to CRM data integration service.

Handling daily syncs at scale

Larger CRMs will often see dozens or hundreds of changes within a given day. Keeping both data sources in sync requires daily or (in the case of Analytics 360) hourly updates.

Doing this manually quickly becomes cost prohibitive. Outside of data cleansing and manual imports/exports you also have to solve a number of problems to maintain data integrity.

Handling updates to contacts

Revenue values within HubSpot will change over time. You will need to devise a method to account for revenue changes per contact.

HubSpot revenue changes replace old values, whereas event values in Google Analytics append to old values as this example below demonstrates.

  • £10k entered in HubSpot Revenue field in April
  • £10k sent to Google Analytics via measurement protocol
  • Additional sale is made for contact and the revenue in HubSpot now equals £12k
  • The new value of £12k is sent to Google Analytics
  • Total value in HubSpot = £12k | Total Value In GA = £22k!

Mapping data across HubSpot objects (e.g. contact level CIDs + deal level metrics)

Client IDs are likely to be captured at contact level within HubSpot. Key business metrics, on the other hand, such as deal value or stage are kept at the deal or company level. 

Furthermore, it’s common to see revenue and sales progression metrics tracked in a completely different CRM system.

Both instances require additional work to stitch up CIDs with metrics before data can be sent to GA and linked to on-site behaviour.

Devising attribution models

Keeping data in sync 100% with HubSpot requires reporting at the event level, which  means having to develop your own attribution model and technology. 

Data volumes quickly become quite large. For a small GA property with 20k monthly visitors, you are likely to need to pull and analyse a couple of million rows of data each month. 

Doing anything more complex than first and last touch attribution becomes unwieldy via Excel and is more easily done with Python. However, this also requires additional technical expertise.

The reports you create with this data are where the majority of the insights are generated.

This is an engaging project for a technically savvy Analytics team but it is not a trivial one, and in our experience is not something you can just pull together overnight. This can take weeks or even months depending on your needs.

We’ve developed our own suite attribution models to power the reports we provide as part of our HubSpot to Google Analytics service. First touch, last touch and linear attribution models are the three that resonate best with our clients.

Actually generating value from the data

This is possibly the trickiest part of the entire process. Once presented, insights need to be explained and buy-in sought from each stakeholder in the marketing department. 

Goals and practices will need to be changed – a process which is far from painless. Teams need to become familiar with new practices and reports before they can start generating value with this new data. 

Suggestions for solving this include working with people who have experience with performance goals and ensuring that moving from conversion/traffic metrics to revenue/lead quality metrics is seen as a logical improvement and not a failure of the current approach.

It’s key that your marketers are aware of the benefits that this integration has to offer. At a fundamental level, reporting on website performance using revenue as your primary KPI is far better using form submissions or even sessions.

I hope this article has been informative. If you have any questions or are interested in setting up a HubSpot to Google Analytics connection, get in touch with us here.

Our Blog