Integrating Google Analytics And Salesforce - A 30,000 Ft View
Salesforce is one of the most popular CRMs available today. Many teams use Salesforce heavily for reporting and analysis. The ability to model the data in Salesforce to fit any organization’s needs is particularly powerful. Many of our clients and Google Analytics training attendees use Salesforce and want to merge data it contains with their Google Analytics data. Thankfully, Salesforce offers a robust set of features to let us integrate the two. The requests I hear most often are:
- Can I see Salesforce data in Google Analytics, e.g. Industry, Customer Type?
- Can I see Google Analytics data in Salesforce, e.g. Source/Medium, Campaign Information, or Goal Completion data?
The good news is, you can! Here are four approaches we might take to do this:
1.) Adding hidden fields to carry in data to Salesforce
2.) Creating a custom Salesforce Trigger and sending the data to Google Analytics
3.) Periodically querying the Google Analytics API and sending that data into Salesforce
4.) Periodically querying the Salesforce API and sending that data into Google Analytics
5.) NEW – Salesforce integrates with Google Analytics 360 and sends back Lead/Opportunity Changes
Today, I’m going to cover four different models for sharing data between these services, as well as why you might like to do each.
Method #1: Adding Hidden Fields
This is the oldest-school way of bringing Google Analytics data into Salesforce: you add Custom Fields to one of your Objects, create a Web Form for that Object, and then populate those hidden fields using data about the user. When the form is submitted, the data is stored in Salesforce.
One of the most common ideas – use the data stored in the
__utmz cookie to see the current user’s Source/Medium and Campaign information. If you’re using Universal Analytics, there are some hoops you’ll have to jump through: E-Nor has one method that may work for you, and I’ll discuss our method in a future post.
The hidden form field method is the simplest way to get Google Analytics attribution data into Salesforce, and also provides the simplest type of insights – essentially, last non-direct click attribution. For companies with longer sales cycles, this might not be the most useful data in the world, but for more demand-generation based folks, this can be super helpful. Again, with some customization, this pattern can be extended to provide more useful information for you to leverage. We’ll cover that in a later post.
Method #2: Creating A Custom Salesforce Trigger
Triggers are a feature in Salesforce that mimic triggers you might have used with database software. Essentially, triggers are conditional rules that you can set up to fire when certain actions take place. This includes, in Salesforce, sending data to outside services. In this way, you can configure Salesforce to do really awesome things like:
- Manage User IDs for your clients
- Update user data in GA when important actions occur, e.g. a big sale closes
- Fill in extra dimensions about users from your CRM into GA, like Industry or CLV
There are some limitations in terms of what Triggers can do – you can only use 10
@future calls (required for sending data to services outside Salesforce) per transaction, and you have a limit of 200
@future calls per Salesforce license, so you may need to be choosy about what you send into Google Analytics with these methods. There are great resources available on how to optimize your code to work within these limits.
This approach is great because you can get near-real-time updates to your Google Analytics data, which can help avoid any data quality headaches.
Method #3: Periodically querying the Google Analytics API and sending that data into Salesforce
Google Analytics has a robust and well-documented API for accessing data from your account. You can take advantage of this and create scripts or services that periodically poll Google Analytics for specific pieces of data, and then submit that data to Salesforce via the REST or Bulk APIs.
Salesforce has a handful of really interesting APIs for all different application needs, which you can check out here. In order to take advantage of these APIs, you’ll need to create a Custom App in Salesforce and build a service on your own server somewhere to orchestrate things.
This approach is how we can bring data from Google Analytics into Salesforce that maybe isn’t available when a form is submitted. For example, we may want to know the first source/medium of a particular visitor’s visit history. With a client- or user-specific key in Google Analytics, we could retrieve that data on a periodic basis and upload it to SalesForce for use in our CRM.
Method #4: Periodically querying the Salesforce API and sending that data into Google Analytics
Similar to Method #3, we can also pull data out of Salesforce using its APIs in order to upload that data to Google Analytics, either using the Measurement Protocol or programmatic Data Import. This method still requires a Salesforce app for authentication and a service on a server to orchestrate things.
This approach is how we can bring data into Google Analytics from Salesforce without using Triggers.
Method #5: Integrate Google Analytics and Salesforce
Announced in 2018, Salesforce and Google Analytics 360 have teamed up to make this process even easier! In a nutshell, connect your Google Analytics 360 account to your Salesforce account and make a small number of changes on your website to enable this feature, included with the with your Google Analytics 360 license. Once that’s finished, Salesforce will send data back to Google Analytics, importing changes to Leads and Opportunities and connecting to the original user that submitted a lead/contact form.
Take a look at our Google Analytics 360 and Salesforce Integration post which describes this process in full detail.
Published: January 17, 2018
Interested in getting started? We can help. Get in touch with us about integrating your Salesforce and Google Analytics data today.
Is your organization sharing data between Salesforce and Google Analytics? Are you doing things differently? Share your models in the comments below.