Skip to content

Google Analytics & CRM Data Integration for Closed Loop B2B Marketing

In order to achieve a Digital Marketing overview, businesses need to close the loop by merging real business data with virtual website data. Picturing full user interactions not only brings you clarity, but it also gives you the power to exponentially increase a businesses’ ROI.

Published on:

black and white portrait of Jonathan Ellins
Jonathan Ellins

Lead Technical Strategist

man merging CRM data with Google Analytics.

Google Analytics & CRM Data Integration can go a long way towards gaining an advantage over your B2B competitors by helping you to understand the full customer journey.

Going beyond cost-per-lead metrics

If you work in the B2B sector, where does your company currently lie on the scale below?
B2B sector scale

  1. Guesswork – Spending a fixed budget towards digital marketing and hope it results in increased leads
  2. Cost-per-Lead Targets – Counting how many leads you receive per month from different campaigns and optimising the average cost-per-lead
  3. Cost-per-Customer Targets – Counting how many new customers you receive per month from different campaigns and optimising the average cost-per-customer
  4. Lifetime Return-on-Investment Targets – Calculating the lifetime value of a customer versus the initial investment on getting that customer, and optimising for a maximum peak.

Businesses who score three or higher on this scale tend to be the ones who are more likely to succeed above their competitors and who can weather any storm since they have the upper hand when it comes to business intelligence.

Why double the number of leads might not result in double the number of customers

Clearly, new sources of leads should be taken with a pinch of salt. While you can receive high-quality leads where people want to become your customer, low-quality leads where contacts are disinterested, or even worse, their details aren’t accurate enough to get in contact, are also common.
Salespeople may instantly reject leads with non-business email addresses, for example, to spend their limited time and effort on the leads which are most likely to convert, the marketing-qualified-leads (MQLs).
In reality, every individual lead has a varying level of quality which may not even be quantifiable, and lies on a hazy scale:
lead quality chart
Therefore, when measuring the success of a campaign, the number of leads even the cost-per-lead from paid advertising isn’t that important. What we need to measure, instead, are the cost per number of qualified leads to see their true value.
qualifying leads

New customers who turn in to repeat customers

Unless your business sells one-off items (gravestones, perhaps?), then a newly acquired customer could turn into a repeat customer with a lifetime value, open to upsell opportunities. 
For example, fast food companies will spend millions to get new customers through the door as they know full well that when people get hooked, they’ll come back again and again. They might spend over a thousand pounds to gain a new customer, even though that customer only makes a handful of profit per transaction:
the mcdonalds curve lifetime value
Identifying loyal customer statistics is nearly as important as gaining new customers for many businesses as repeat customers provide a safe and steady income.

The user data threshold

On one hand, we have a wealth of website data, typically collected through the Google Analytics platform. On the other, a wealth of business data from the customer relationship management (CRM) platform which holds data on leads, qualified leads, customer details and repeat customer details.
google analytics client tracking
As shown, Google Analytics can only track users from their initial website visit, up to the point of lead conversion. Beyond this hurdle, the CRM platform processes and stores the user data, causing a costly disconnection of information between the two platforms

Closing the loop between analytics and CRM

For every website visitor, Google Analytics assigns each user with a Client ID, a 20 digit number divided with a full stop, which contains these properties:

  • Random unique ID – 10 digits long
  • Client ID – 10 digits long
  • Format: [random unique id].[client id]
  • Example: [1234567890.0987654321]

Future information about users can be amended to Google Analytics if we use the Client ID as a unique identifier for each individual user:
using the Client ID as a unique identifier
To achieve this feedback loop, we must perform three tasks. These, ideally,  should be automated using hourly, daily, weekly or monthly triggered scripts:

  1. Collect the Client IDs for any user who submits a lead within the CRM platform
  2. For every stage of lead-nurturing, export relevant information along with the associated Client ID out of the CRM
  3. Import this data into Google Analytics

CRM integration
See Google’s summary of CRM integration here.

Importing Client IDs into a CRM

A user’s Client ID is extracted using the script below which accesses Universal Google Analytics once it has loaded. Google Tag Manager is a handy tool for performing this task:

ga(function(tracker) {
  var clientId = tracker.get(‘clientId’);

For every form on the website, we can add a new field within the form and auto-populate it with the dynamic Client ID:
form field with Client ID
If the form is ever submitted then the user’s unique Client ID will automatically be submitted along with it, and that information can be stored as a new field within the CRM platform for each contact record.
For an added bonus we can hide this form field from view so users are unaware of its existence when they are using the website.

Exporting new lead/customer information

There are several stages of lead nurturing and customer milestones which each business has, many of which are unique to the business itself, locked within the CRM platform.
Common examples of useful pieces of information include:

  • If a lead is marked down as a qualified lead
  • If a qualified lead becomes a new customer
  • If a customer makes a subsequent purchase
  • If a customer is lost or has negative feedback
  • If a customer attributed to any new customers

This data needs to be exported out of the CRM platform, ensuring that any personally identifiable fields are not exported to appease privacy laws, such as:

  • Name
  • Address
  • Email address
  • Phone number
  • Payment details

lead information with Google Client ID
The only identifiable field to extract is the Client ID, which is set by Google Analytics. As only Google knows the personal details behind that ID, this ensures 100% data security as a Client ID has no use to any potential eavesdroppers
The export can be in any format, but the most commonly used ones are:

  • Spreadsheet formats (txt, csv, xls, etc.)
  • Direct REST API connections (JSON output)
  • Direct data acquisition and processing from the CRM platform (no export used)

Updating Google Analytics with the new information

Google Analytics has a couple of data integration options to pass the information to them:

The manual method works well enough if you have very little data to work with. You can also edit transaction revenues using this method if, for example, a customer wanted a refund after initially paying for goods or services.
The automatic method requires some advanced development which quite often needs to be bespoke to use the data set provided – Hallam can offer this service with our proven scripts and methodologies if needed.
Data is passed through URL parameters appended to the data collection server URL, for example:

It’s difficult to read, but the example HIT data above sends this information:

  • Type – Event
  • GA Property ID – UA-1234567-89
  • Client ID – 1234567890.1234567890
  • Event Category – crm
  • Event Action – new-customer
  • Event Value – 1234

This event can be linked to a goal within Google Analytics with a dynamic Goal Value taken from the Event Value. This user will now have real-world value added to their original website data for more in-depth reporting.
Google provides two servers for this data, a validation server where you can test HIT data out for errors and the main analytics data server to collect and apply the information:

Boosting your ROI based on data, not feelings

Once you have closed the loop and have gathered enough customers to be statistically significant, how do you use this data to the best of your advantage?

Squeezing more value from paid media channels

For paid advertising, we can ditch outdated cost-per-lead targets and concentrate on more accurate cost-per-customer or maximise ROI targets.
Different campaigns, demographics, locations and devices will have different conversion rates, not only at the lead-generation stage but also beyond this, including:

  • Lead Generation > Qualified Lead Generation
  • Qualified Lead Generation > Initial Customer Value
  • Initial Customer Value > Repeat Customer Value

Once the conversion rates for all steps towards a new customer are considered, only then can we segment the data and get meaningful results:
table showing customer data
table showing customer data
We can see above that although the younger ages convert less (a higher cost-per-lead), they actually are more likely to convert overall with the increased likelihood in the later stages of converting outdoing the initial lead generation.
The full loop conversion rate of any segment allows you to reverse engineer the ideal cost-per-click to achieve the target cost-per-customer:

Ideal Cost-Per-Click = Target Cost Per Customer x Full Loop Conversion Rate

Feeding data back in with the lifetime value of the customer, plus any additional revenue from upsells or friend referrals gives an even clearer view on a segment’s performance. Without this knowledge, campaigns may have been boosted or held back based on only the first half of the data available and may have the opposite effect overall. 
Combining all in-goings and out-goings shows the overall return-on-investment and these values can all be fed back to Google Analytics, such as:

  • Ad costs
  • Customer Revenue (plus repeat revenue)
  • Product costs (if any)
  • Business costs per customer
  • Upsell revenue

Spotting which media campaigns actually work

Online campaigns can come from several sources, including email, social media, paid media and referrals.
Instead of throwing money blindly at a social media campaign, hoping that it works out, by closing the loop you can now see the true value and measure what returns you are getting on different channels.
All links can have a campaign name attached to them using UTM parameters. Even non-paid links can be associated with a campaign name such as on a standard tweet or Linkedin post.
Google Analytics model comparison tool
The model comparison tool within Google Analytics allows you to measure the impact of different campaigns and allows you to see different attribution models which suit the campaign’s point in the funnel:

  • First Interaction – The first time a user visits your website is when they are counted
  • Last Interaction – The last time a user visits your website is when they are counted
  • Position Based – The first interaction counts towards 40%, the last interaction also counts towards 40% and any intermediate interactions count towards the remaining 20%
  • Last Non-Direct Click – The last time a user visits your website is when they are counted but skipping out any direct visits

The position-based model is one of the most useful models as it shows a campaign’s involvement in attracting new visitors (the first interaction), if the campaign was successful in converting (the last interaction) and any mid-point influences the campaign had towards the final conversion.

Using Google Analytics to analyse your CRM data

It’s not all about combining website data with business data, once you import CRM data in Google Analytics you can now do a full analysis on it with Google’s free and powerful analytics platform.
Google Analytics has some great in-built reports which can reveal useful metrics such as average order values, average conversions per user and the number of days it takes on average from a user turning from a lead into a real customer.
You can add personal CRM data into Google Analytics if you are extremely careful not to add in any data using plain text or in a way which can be easily deciphered. Personal data added to Google Analytics could result in a permanent ban from the platform as well as breaking data privacy laws in many countries if not added correctly.
One possible way of adding personal data to Google Analytics without breaking user-privacy is to use a salt and hash algorithm which scrambles the data in a virtually non-reversible way and has no repetitive nature as a random salt is used for every piece of data:
salt and hash algorithm
Image from
If three separate users had the same name, for example, the resulting hash would still be completely different and a reverse-engineered solution wouldn’t be possible such as the machine Alan Turing used to crack the Enigma code.


Armed with data from the full customer journey, B2B businesses no longer have to shoot in the dark when it comes to making or measuring online investments.
Use a closed-loop approach to optimise with cost-per-customer targets or even further by maximising ROI to gain a huge advantage over competitors.

Get content like this in your inbox, weekly.