This detailed step-by-step guide will show you how to integrate Salesforce.com with Google Analytics 4.

What Will a Salesforce and Google Analytics 4 Integration Do For You?

The goal of marketing is to drive revenue.

But Google Analytics 4 is only good at measuring sales that happened right on the website (e.g. an e-commerce store).

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 only capture what your customers do on your website, you’re missing out.

You don’t know how many of your website visitors actually became paying customers.

The Method

In this article, we will provide a step-by-step method for bringing information about your buyers from Salesforce into Google Analytics 4.

We’ll utilize a really cool Google Analytics 4 feature called Data Import to pass customers’ lead information from Salesforce into Google Analytics 4. In this particular article, we will explain how to import Lead Status data into Google Analytics 4.

Once you do this you’ll be able to build interesting Google Analytics 4 reports with Salesforce data, like this:

Salesforce Google Analytics integration result example

Overview of Implementing of Salesforce & Google Analytics 4 Integration

To import Salesforce data into Google Analytics 4, we need a key that will unite CRM and Analytics data. We’re going to use the Google Analytics Client ID – a cookie generated by Google Analytics 4 for each browser viewing your website.

This key will be tracked in Google Analytics 4, and stored in Salesforce – as a custom field.

This integration takes only five simple steps.

In steps 1-2, we’re going to create lead status as a custom dimension, then save the client ID to Salesforce as a custom field.

Then, in steps 3-4 we will use GA Data Import to automatically merge this data in Google Analytics 4.

Finally, in step 5 you’ll find your Salesforce data in Google Analytics 4 and learn how to use it.

Key Results

When you bring Lead Statuses from Salesforce into Google Analytics 4, you’ll be able to build all kinds of reports with this data to answer questions like:

  • Which campaigns, ads, blog posts and keywords drive the most qualified leads?
  • Which traffic sources only drive junk traffic that distracts your sales reps from valuable customers that your company can actually help?
  • How is the behavior of your qualified leads on your website different from that of your unqualified leads? (this question can be answered by building two segments and comparing them)
  • What pages do your qualified leads visit most frequently? (you may want to focus more of your attention on those)

Step One: Create Custom Dimensions

1. Go to your Google Analytics 4 property, and click Admin – Custom Definitions – Custom Dimensions.

2. You should see something like this:

Custom Dimensions

 

3. Click New Custom Dimension and create a new user-level custom dimension like this:

Lead Status

4. Remember the name of this new custom dimension(from the user property field). We’ll need it in step 2.

Step Two: Save Google Analytics Client ID to Salesforce

Now we need to save the Google Analytics Client ID to Salesforce, so we can use it as a key when merging data.

To do this:

1. Add a new custom field to your Salesforce Lead object.

2. Then, create a new hidden form field and connect it to the new custom field.

This saves the value of the hidden field to Salesforce during form submission.

The hidden field should look something like this:

3. Finally, add code resembling this to your website:

This code will automatically retrieve the value of the GA Client ID and put it in the new hidden field we just created.

Step Three: Create a Data Set File with Salesforce Data

Now we just need to fill this file with actual data from Salesforce.

To do this, open Salesforce navigate to Reports and create a new lead report. Then, export this report as a CSV file:

Salesforce export menu (to generate a file for Google Analytics import)

Salesforce export menu (to generate a file for Google Analytics import)

Now update the exported CSV file to match the Google Analytics 4 requirements. The CSV file should look something like this:

CSV Format

Make sure you are using a text editor to edit and save the CSV file. Make sure not to use Excel, since the client ID number formatting may cause issues.

You can download the CSV template here.

To find your stream ID, go to Admin – Data collection and modification – Data streams. Then open the data stream you have created. The stream ID is located on the left side of the details header.

Step Four: Upload the Salesforce dataset to Google Analytics 4

Go back to Google Analytics 4 – Admin – Data Import, and click “Create Data Source”.

  • Choose the data source name (e.g. something like “CRM data”).
  • Select User data by Client ID for the data type.
  • Then you can upload the CSV file you prepared in the previous step.

GA4 import

Once you click Upload CSV, you will be asked to map the fields.

Once you map the fields, click “Import”, and wait for the file to be imported.

Note: If you see an ‘unknown’ error while uploading, most likely you are logged into multiple Google accounts. In which case you can try again using incognito or a different browser where you can log in with one email address only.

Step Five: Find the Salesforce Data in Your Google Analytics 4 Reports

Now go to one of your GA reports like Traffic acquisition, and add a custom dimension to the report by clicking Secondary Dimension – Custom Dimensions – Lead Status:

Salesforce Google Analytics integration result example
Note that the uploaded data needs to be processed before it will show up in reports. Once processing is complete, it may take up to 24 hours for the imported data to be applied to incoming hit data.

The steps above explain sending Lead Status information to Google Analytics 4, but you can also send information about the Opportunity object too, you just need to map the Google Analytics Client ID to the Opportunity object, you can follow the steps in this article on how to map the field to the Opportunity object.

Congratulations! Now you can see which campaigns, keywords, ads, pages, blog posts etc produce the most qualified leads.

Next Steps

Bringing in lead statuses is a great first step toward revenue-driven marketing.

But there are tons of other data points you can import to Google Analytics 4 from Salesforce.

These include revenue, profit, number of successfully closed won deals and more.

Right now GA Data Import only lets you import custom dimensions.

It doesn’t let you bring in metrics (e.g. revenue), track goals, or do other stuff you may want to do.

To do this, you can use a tool like GA Connector which enables you to bring any kind of data from Salesforce into Google Analytics 4 automatically, without uploading any spreadsheets.

With GA Connector you’ll be able to build even more powerful Google Analytics reports with offline data:

ga4-report

Happy analyzing!