Google Analytics and Salesforce Integration 101

Table of Content:
- 5 reasons to integrate your Google Analytics and SalesForce Sales Cloud data
- Improve your Attribution Model
- Better segmentate your Remarketing Campaign
- Excluding your Customer from Paid Audience
- Segment your customer better and analyse their behaviour
- Reconcile Sales & Marketing teams
- How to integrate Google Analytics data in Salesforce
- How to integrate SalesForce data in Google Analytics
Digital Marketing is well known for its ability to track pretty much anything you want about your customer journey…your online customer journey. And this is great for eCommerce and online pure players, as they’re able to thoroughly analyse their whole sales funnel. But what about businesses – like most B2B companies – that rely on sales teams to prospect and close deals? How do you reconcile what happens online with what happens offline?
Well, let’s be honest, it isn’t an easy process, and that’s why lots of Marketers just settle for the information made available to them off the shelf and accept information gaps as a fatality. So, let’s go a step further together today and see how we could boost our sales and marketing performances by simply integrating Google Analytics and Salesforce – these two tools that rule our daily operations:
5 reasons to integrate your Google Analytics and SalesForce Sales Cloud data

1- Improve your Attribution Model
We all know that Attribution Models are very important to help us understand how marketing efforts impact the business bottom line. Indeed, they enable companies to understand the number of sales generated by each channel and the ROI of those channels or campaigns, and, therefore, where to make the next investment.
However, we often notice two common pitfalls in B2B companies:
- Marketing teams are looking at Attribution Models in Google Analytics which are great, as they enable you to compare several models (first touch, last touch, decay, linear, U shape….). However, if you don’t have your CRM data linked to Google Analytics, you will most likely take Leads as a conversion end point and then you just have part of the picture as you don’t know which of those leads really became a sale, which can then lead you to bad decisions.
- The other very common scenario is to collect the last source before form submission in Salesforce and decide to base your attribution analysis in Salesforce, based on this sole information. Here again, you’re getting only one part of the picture and overlooking your customer journey, which may lead to a wrong conclusion.
By synchronizing your opportunity stages in Google Analytics and your user touchpoints in Salesforce you are now able to understand which campaigns or channels generated the most qualified leads more revenue.
2- Better segmentate your Remarketing Campaign
You may already be creating audiences in Google Analytics to remarket your customer more effectively in Google Adwords. To create an audience is easy – you just need to create a segment in Google Analytics filtering using the criteria available like page view or time on page.
That’s great, but what if you could have some CRM data available in Google analytics and start creating an audience based on Customer Tiers, Sales Stage, Last Active date…?
By adding Salesforce information in Google Analytics you could now create a segment in Google Analytics based on the data available in your CRM and remarket your users accordingly. How powerful is that?
3- Excluding your Customer from Paid Audience
Following the same logic as before, you could create a segment in Google Analytics which captures only the users who are already clients (information available in your CRM) and then use this segment as an exclusion audience in Adwords.
This way, you will avoid losing money in showing acquisition campaigns to your existing customers.
4- Segment your customer better and analyse their behaviour
As soon as you connect the 2 platforms, you’ll be able to go deeper in your analysis than you ever thought. You’ll have a brand new range of possibilities like:
- Segmenting your reports based on your CRM data
- Displaying your Salesforce data as a secondary dimension in all standard reports or creating your own custom reports
- Tracking your CRM achievements (ie: opportunity closed or won) as Google Analytics goals
5- Reconcile Sales & Marketing teams
Most B2B companies have a sales team involved in the opening, nurturing, and closing of a deal. Unfortunately we often witness arguments between sales and marketing teams about who generated the lead in the first place. Was it done through Sales Actions or Marketing Campaigns? Does that ring a bell?
These two teams can then easily get an unhealthy competition mindset, when it would be far better if they tried to understand what the best combination of actions would be – as a team – to successfully open and close a deal.
All the touchpoints matter and there’s very rarely a sole touchpoint from start to end, so the most important thing to understand is how campaigns and channels influence deals.
Salesforce has a built-in Campaign Influence and Attribution Model system. So, if you can properly feed all the touchpoints in your CRM you’ll finally be able to reconcile online and offline activity.
How to integrate Google Analytics data in Salesforce

At this stage in our article we need to confess something: when we talk about integrating Google Analytics Data in Salesforce it is, most of the time, a lie. But don’t get mad – here’s why: Properly extracting the information from Google Analytics to input it into Salesforce is something which can be challenging, unless you have Google Analytics 360.
If you do have it, lucky you! If not, you can keep reading, but you’ll need to understand that most of the tools and methodology tend to replicate Google Analytics behaviour to collect traffic sources.
How is that?
Google gets its traffic source information from a file located at the root of any webpage and available to anyone: the document.referrer. I don’t want to go too deeply into technical details, but, basically, this file contains the URL where the user comes from before landing on your website and, based on this URL, Google retrieves the source thanks to a simple algorithm which will do the following:
- If the URL has a gclid parameter, set the medium as CPC
- Or, if the URL has UTM information, then set the medium as the UTM says
- Or, if the URL domain is google.com, bing.com, yahoo.com… then set the medium as Organic
- Or, if the URL domain is www.myfriendwebsite.com set the source as referral
- Or, if I don’t have information about the previous URL, then set the source as Direct Traffic
Well, OK, I oversimplified it a bit, but I’m sure you get the idea, and that you now understand that if you can get access to this URL, then it’s not very complicated to replicate Google Source Traffic information.
OK, so let’s see how to feed SalesForce with Google Analytics traffic source information
Do it yourself approach
If you have some tech resources available, you can decide to retrieve the Google Analytics traffic source tracking yourself. To do this, you can either use some open-source code like Sourcebuster or GetSet Reff, or you can go all-in and create your own code.
Here are the steps you’ll want to follow:
- Build a piece of code to help you retrieve the user source following the algorithm we described previously
- Store it into a cookie – here you decide whether you want to store only the first touch, last touch or all the entry points…
- When the user submits a form, pass the information stored in the cookies to Salesforce through hidden fields or APIs.
- Once in Salesforce, create workflows and process builders to send the leads to the campaigns based on the information you collected.
You’re now all set to analyse your campaign influences.
Using SALESFORCE and GOOGLE API
This method also requires technical resources and a good understanding of Google and Salesforce databases. Basically, both platforms have great and powerful APIs that could allow you to transfer information from one tool to the other. How?
- Choose a common ID to identify visitors or users in both systems (it could be Google CID, or your CRM User ID) and make it available in both tools.
- On a periodic basis, you can query Google API for a given User ID and collect the information you want.
- Then you can upload it directly to Salesforce using its API
- Now you have all the sources refreshed periodically and you can send your user to the respected campaigns that they interacted with
Off the shelf solutions
If you only have limited IT resources available, you might want to go for an off the shelf solution that could cover your needs. In this article, we listed some of the tools we found worth considering.
Now that you’ve collected your traffic source in Salesforce, it’s also important that you associate the leads to campaigns, reflecting the sources that each lead interacted with. This could be a whole article in itself, so I won’t go into this just now. However, just make sure you build a proper campaign structure so that you can analyse one-shot campaigns like your Summit Event as well as generic campaigns to collect generic sources like Organic users from Google.
By doing things this way, you’re now able to analyse the Offline and Online campaign influence on the different opportunities generated and, in turn, the revenue generated.
How to integrate SalesForce data in Google Analytics

As we explained before, uploading Salesforce data into Google Analytics is a big upgrade for your marketing strategy. Let’s see how this is done.
Choose a common ID
In order for Salesforce and Google Analytics to communicate together, you’ll need to choose a common identifier (ID). The most usual solutions are either:
- Using the CID already generated by Google for each user. In this case, you would need to capture the ID from the cookies and send it to Salesforce through a hidden field each time a form is submitted.
- Using your CRM ID that you’ll send to GG analytics. To do this, you would normally send your ID to the dataLayer when a user is submitting a form, collecting it from the dataLayer with GTM and sending it to Google Analytics from there through a custom dimension you defined for this field.
If you’re going to go for the second option, then be careful to respect Google Privacy Policy. In Google Analytics, you can’t store any personal information about your user that could lead to them being identified.
Create the fields in Google Analytics to collect your CRM information
In order to store your CRM information in Google Analytics, you’ll need to create the fields where you’ll store this information: the custom dimensions. To do so, you can follow this guide. It’s quite simple, but choose the fields wisely as you’re limited to 20 fields on the free version of Google Analytics.
Prepare your hits to the Measurement Protocole
Now that you have the fields ready to store Salesforce information in Google Analytics, along with your unique identifiers to recognize your users on both platforms, you’re ready to send Salesforce data to Google Analytics. To do so, you’re going to use the Measurement Protocol.
This is basically a URL hit containing all the information you want to send to Google Analytics.
IE: https://www.google-analytics.com/collect?v=1&t=event&tid=UA-12345-6&cid={{the client id from the CRM}}&ec=measurement+protocol&ea=lead+updated&el={{the lead status updated}}&cd1={{the lead status updated}}&ni=1
Each time this URL is loaded, Google Analytics receives and stores the information it contains. Note that you will need to identify your GG Analytics Account, as well as the Client or User ID.
Synchronize SalesForce and Google Analytics
Now, you’ll need to ask your developers to automate this task in Salesforce in order to periodically send the information that has changed to Google Analytics. Either on a daily scheduled task, or each time there’s a relevant change in Salesforce, the system will basically recreate the URL we’ve seen before with the relevant information to be sent to Google Analytics.
We hope this overview of what Google Analytics and Salesforce integration can really do will help you go one step further in your B2B Marketing strategy. We’ll go more into detail for each section in future articles, but, in the meantime, why not drop us a line or ask us a question in the comments section below?