Integration of Salesforce with Google Analytics

Integration of Salesforce with Google Analytics

What is Google Analytics?

Google Analytics is a web analytics service that provides statistics and basic analytical tools for search engine optimization (SEO) and marketing purposes. The service is part of the Google Marketing Platform and is available for free to anyone with a Google account.

Benefits of Google Analytics:

  • It can improve online ads with the use of marketing analytics.
  • It can understand your Target Customers.
  • It tracks your goals as well as online traffic.
  • It has in-built data reports and the option to customize reports according to your KPIs.
  • Suggestions for better performance improvisation.

What can Google Analytics and Salesforce Integration Do For You?

The aim of marketing is to drive revenue and Google Analytics is good for measuring sales that happened on the website, e.g. an e-commerce site, but most businesses don’t work this way. Sales are often closed by sales reps and only tracked in Salesforce or some other CRM software. If you capture specific things about what your customers do on your website, then you’re becoming limited, you may be missing how many of your website visitors actually became paying customers.

Why do integrate Salesforce with Google Analytics?

  • It offers a wealth of extra data to help enrich your marketing and lead generation. We found that 37% of marketers found generating high-quality leads to be one of their biggest challenges.
  • It can help you analyze the visitor’s behaviour and how they are interacting with your business. If you have this kind of setup, it’s already pretty slick, and you can effortlessly get customer inquiries for your product or service. 
  • To get exactly which marketing channels are generating high-quality leads.
  • This integration gives you a 360 view of your marketing campaigns.
  • It will be useful to see any trends across a certain time frame. With the help of data collected in GA, you can also check which campaign has been most efficient and plan for future marketing campaigns. These answers are impossible to answer without connecting your Salesforce Lead & Opportunity data, with Google Ads.

Steps for Integration of Salesforce to Google Analytics:

Step-1 : Decide how to identify your users

Google Analytics offers you 2 ways to identify your users: Client ID and User-ID. To support Data Import for Salesforce Sales Cloud, you must implement Client ID. You may optionally choose to also implement User-ID.

Client ID:- identifies a browser instance. This is a cookie-based identifier created automatically by an Analytics-enabled site on a user’s first visit. Identifying users with Client ID is best suited for businesses focused on lead generation and new customer acquisition. Apps or sites for this type of business are typically having low rates of user authentication and retention.

User ID:- enables the analysis of groups of sessions, across devices, using a unique, persistent, and non-personally identifiable ID string representing a user. This option is best for businesses with high rates of logged-in users. Implementing User-ID requires some additional setup and code on your site:

Step-2 : Required Salesforce Sales Cloud objects and fields

For the setup of the Analytics Salesforce Sales Cloud integration, you should have full access to the following Salesforce objects and their fields.

Objects Required Fields
LeadStatus ID
MasterLabel
SortOrder
LeadHistory CreatedDate
OldValue
NewValue
Lead Status
GACLIENTID*
GAUSERID*
GATRACKID*
OpportunityStage ID
MasterLabel
SortOrder
IsActive
OpportunityFieldHistory CreatedDate
OldValue
NewValue
Opportunity Amount
StageName
GACLIENTID*
GAUSERID*
GATRACKID*
OpportunityLineItem All fields
Product2 (Products) All fields
Pricebook2 (Price Books) All fields
Step-3 : Create new custom fields in Salesforce Sales Cloud

You must have to create all the below 3 fields, no matter which tracking method you decided. Field names must be in uppercase. You can give any field names you want, and make these fields read-only to avoid unwanted changes. And these fields should be created on both the Lead and Opportunity objects.

Field Name API Name Length
GACLIENTID GACLIENTID__c 255
GAUSERID GAUSERID__c 255
GATRACKID GATRACKID__c 255
Step-4 : Configure the Lead and Opportunity objects

For the both Lead and Opportunity object, enable Field History Tracking for the “Lead Status” and “Stage”. It will track the history if any update to these fields is happened.

Also, Map the Lead fields for the conversion to the respective fields in other objects:

  • Lead.GACLIENTID to Opportunity.GACLIENTID
  • Lead.GAUSERID to Opportunity.GAUSERID
  • Lead.GATRACKID to Opportunity.GATRACKID
Step-5 : Edit your lead form

Now you have to do changes in your lead form to capture and store the tracking information.

Also, you have to know your Analytics tracking ID.

Add the Custom Tracking Fields:-

Below is an example which shows how you can add custom fields to your lead form using JavaScript.

<form action="" name="myForm">
    Phone: <input type="text" name="phone_number">
    <input type="hidden" id="GACLIENTID" name="GACLIENTID" value="">
    <input type="hidden" id="GAUSERID" name="GAUSERID" value="">
    <input type="hidden" id="GATRACKID" name="GATRACKID" value="XX-XXXXX-XX">
    <input type="submit">
</form>

You can remove the GAUSERID line if you are only using a Client ID.

To set the tracking ID, replace XX-XXXXX-XX it with your Analytics tracking ID. Alternatively, you can retrieve the tracking ID dynamically using this code:

<script type=”text/javascript”> 
    ga(function() { 
      var tracker = ga.getAll()[0];
      var trackingId = tracker.get('trackingId');
    });
</script>

Then replace the hard-coded tracking ID (XX-XXXXX-XX) with the trackingId variable.

Set the custom tracking field values:-
Add this code to your lead form to populate the Client ID and User-ID values.

<script type="text/javascript">
    document.getElementById('FORM_ID').addEventListener(
    'submit', function(event) {
      ga(function() { 
        var tracker = ga.getAll()[0];
        var clientId = tracker.get('clientId');
        document.getElementById('GACLIENTID').value = clientId;
        var userId = tracker.get('userId'); 
        document.getElementById('GAUSERID').value = userId; 
      });
    });
</script>
Step-6 : Link Analytics to your Salesforce Sales Cloud account

You need to link Analytics to your Salesforce Sales Cloud account by creating a new Data Import data set and then by authorizing access to your Salesforce Sales Cloud account.

Create a Salesforce Sales Cloud data set:-

  1. Sign in to Google Analytics.
  2. In the bottom left, click Admin, and navigate to the property to which you want to link. You must have the Editor role for this property.
  3. In the PROPERTY column, click Data Import.
  4. Click CREATE.
  5. For Data Set Type, under CRM Data, select Salesforce.
  6. Read and accept the Additional Terms for Analytics Salesforce Sales Cloud Data Import.
  7. Under Data Set details, name your data, then click Continue. The Data Source details panel appears.

Click the current credentials to see a list of all your successfully created Salesforce credentials. To remove unused credentials, on the right, click X. If the credentials are currently in use, you must disable those before you can remove them.

Authorize Salesforce Sales Cloud:-

  1. In the Data Source details panel, under Salesforce credentials, select Create new authorization.
  2. Enter a Credentials name to reuse.
  3. Click Access Salesforce.com.
  4. In the Salesforce pop-up, log in to your Salesforce Sales Cloud account. Once you’ve successfully logged in, the link to Analytics is complete. The new credentials name appears in the Salesforce credentials drop-down menu.

Tracking fields setup:-

In the Tracking fields setup panel, it lets you map your configured Salesforce fields to the corresponding Analytics Tracking IDs. For each Tracking ID in use, select the corresponding Salesforce custom fields.

Once the configuration of the tracking fields is completed, click Continue.

Step-7 : Configure the Salesforce milestones to import

Here you will select the Salesforce lead and opportunity milestones to import. You also need choose how often to import them.

  1. In the Data Source details panel, under Milestones Selection, use the drop-down menus to select the milestones you want to import.
  2. Click Continue.

Attribute and Product data setup (optional) :-

Attribute data import allows you to import user attributes from custom fields and selected standard fields from your Salesforce Lead and Opportunity objects. You select the Analytics custom dimensions and custom metrics that will store this data.

Product data import allows you to import product data from your Salesforce account. This data is imported as part of the same Measurement Protocol hit as your milestone data.

While optional, importing attribute and product data is recommended, as it enables a wide variety of new audience targeting and analysis use cases.

Standard supported fields:-

You can import attributes from the following standard Salesforce Lead and Opportunity fields:

Opportunity Fields Lead Fields
Id Id
Amount Industry
CampaignId NumberOfEmployees
ContractId Rating
ExpectedRevenue ScoreIntelligenceId (if available in your Salesforce Edition)
LeadSource  
Name  
Probability  
TotalOpportunityQuantity  

Example configuration:-

Below is an example of a supported standard Salesforce fields and Analytics custom fields mapping,

Analytics custom field: scope Salesforce field name
Dimension: session OR user Lead: Lead ID
Dimension: session OR user Lead: Lead Score (Salesforce Einstein predicted score)
Dimension: user Lead: Industry
Dimension: session OR user Lead: Rating
Dimension: session OR user Opportunity: Opportunity ID
Metric: hit Opportunity: Amount
Dimension: session OR user Opportunity: Probability (%)
Metric: hit Opportunity: Expected Amount
Dimension: session OR user Opportunity: Order Number

Supported formats:-

You can import all custom attribute fields with the following Salesforce field formats:

boolean dateTime (camelCase)
currency percent
date picklist
datetime string
double textarea
int time

To import attributes:-

  • Select the Analytics custom dimensions and/or custom metrics that you want to contain the attribute data.
  • Make sure that the selected custom dimensions have the correct scope. In most cases, this will be user scope.
  • Use the drop-down menu in the Salesforce field name column to map the Analytics fields to your Salesforce fields.​
Step-8: Enable product data import

To enable product data import, you should have the following configuration:

  • Product data is configured in your Salesforce account.
  • At least one view in the current Analytics property has Enhanced e-commerce enabled.

Then you can enable product data import by following the steps:-

  1. Below the attribute import table, click Enable Product data import.
  2. You can then review the field mapping between Salesforce product data and your Analytics Enhanced E-commerce fields.

Data Source schedule:-

Use this option to set up the import frequency.

  1. Click Continue.
  2. Click Done.

Note:- Fetching the data every hour for the highest freshness, accuracy, and availability.

Step-9 : Test Your Setup

In the final step, you can test your configuration by importing some data and check it in an Analytics report.

Import data
  1. If necessary, return to the Data Set list page:
    1. Sign in to Google Analytics.
    2. In the bottom left, click Admin, and navigate to the property that contains your Salesforce Sales Cloud data source.
    3. In the PROPERTY column, click Data Import.
    4. The Data Set list page appears.
  2. Locate the data set you created in the previous steps.
  3. On the right, click Manage uploads.
  4. In the Uploads for Salesforce Offline Conversions page, click More > Fetch Now.

This will upload your Salesforce data to Analytics. If the upload is successful, the Status shows as “Completed.” If an error occurs, the Status show as “Failed” with a link to display more details.

In the top right corner, you can also check whether your Salesforce Data Set is scheduled for automated imports.

View imported data in a report:-
To view imported milestones
  1. Navigate to the BEHAVIOR > Events > Top Events report.
  2. Adjust the time window to include your uploaded data.
  3. Apply a Secondary Dimension of Event Label

If your Salesforce milestones have been successfully imported, they should now appear in your report.

To view imported attributes:-

To check imported attributes in any Analytics report, add the custom dimensions you’ve mapped in the configuration steps as secondary dimensions.

To view imported product data:-

To see imported product data, use Conversions > Ecommerce > Sales Performance or Conversions > Ecommerce > Product Performance reports. Adjust the time frame to verify the imported product data. For example, if you started importing data today, make sure your report time frame includes “today.”

Product data is imported with Opportunity milestone events. It may take additional time before a lead is converted to an opportunity in your Salesforce account.

Summary :

The integration of Salesforce with Google Analytics is a game-changer for businesses aiming to drive their success to new heights. By merging these platforms, you can gain invaluable insights into your marketing campaigns, effectively track conversions, and optimize your sales funnel. With improved data analysis capabilities, you can make data-driven decisions that will pave the way for better marketing strategies and accelerated business growth.