Importing Google Analytics Data into Salesforce

This is a tutorial on how to manually import Google Analytics data into Salesforce. It is designed for customers of the CloudAmp Analytics Dashboards, who might want to import historical data beyond the last 30 days that is automatically imported when you first install the application (soon to be customizable for different time periods), but it will also work for any Salesforce setup.

If you are not a CloudAmp customer, keep in mind that you would need to create a custom object and fields to hold your Google Analytics data inside of Salesforce.  You could always try CloudAmp Analytics Dashboards free for 7 days, since it takes just a few minutes to set up. It might be just the thing you are looking for, since it gives you all of the data and dashboards preconfigured, not to mention automatically loading your Google Analytics data nightly into Salesforce. But obviously I am biased here. 😉

Anyway, with that plug out of the way, how can you import Google Analytics data into Salesforce, either as a permanently manual process or to supplement data from an existing integration?

Here is a step by step tutorial. Please note that steps 1-3 are optional. If you like to live on the edge, you can simply export data from Google Analytics and then match up the columns when importing into Salesforce, rather than create an import template first.

Building an Import Template

1. Find the prebuilt report called “CloudAmpGA Metrics Export Report” (or create your own).

Google Analytics Import 1b

2. Export to CSV

Google Analytics Import 2b

3. Prepare the CSV file to become an import template. The main reason we exported was to get the appropriately named header row, and some of the profile data.

Google Analytics Import 3b

  1. Delete all rows of data except for the header and first row

  2. Delete these columns, since they will be auto-generated by Salesforce when new data is imported

    1. CloudAmpGA Metrics: Metrics Number

    2. CloudAmpGA Metrics: ID
      Google Analytics Import 4

  1. Delete all other data from first sample row, except for

    1. Profile_Id

    2. Profile Number

    3. Profile Name
      (you want to save these values to match with the Google Analytics profile(s) that you will be importing).

Exporting data from Google Analytics

Log into Google Analytics, select the profile you want, and set the date range to the periods of data that you wish to  import into Salesforce. Export the relevant data from Google Analytics for the metrics and date ranges you want into a CSV file.

This step can be the most difficult, as different metrics are stored differently of Google Analytics. Google Analytics limits which dimensions can be related to which metrics, so creating exportable reports that will be formatted in a useable way can be a challenge for some of the data. For the CloudAmpGA Metrics custom object in Salesforce, for example, where daily records are stored for the CloudAmp Analytics Dashboards app, not all of the metrics are cleanly exportable as columns in a CSV file.

  1. Go to the “Customize” button and create a Custom Report.
    Google Analytics Import 6

  2. Select “Date” for the dimension

  3. Select the metrics that you wish to export.
    Google Analytics Import 7b

  4. Save the report and export to CSV.
    Google Analytics Import 8b

Important Notes:

  1. Only 500 rows of Analytics data can be exported at a time into CSV format. Google has some tips for exporting larger data sets in the Google Analytics help documentation.

  2. Note that not all metrics are available in custom reports, or at least not in an easy-to-export way. You many need to create additional reports and manually move data around, and/or use some formulas in certain columns of your spreadsheet to calculate some metrics. In the Custom Report example below, for example, adding “Traffic Type” as a second dimension produces some of the data we want (Organic Visits, Referral Visits, Direct Visits) but as multiple rows per date instead of a column.

  1. Google Analytics Import 11Google Analytics Import 10b

Preparing the Google Analytics data CSV file

  1. To prepare the CSV file, make sure column headings are as close to Salesforce field names as possible. Either use the CSV template created in the first part of this tutorial, or manually update the column headings to match the Salesforce field names.
    Google Analytics Import 9

  2. (If importing into the CloudAmpGA Metrics object): Ensure that the Profile Number is populated, and the Metrics Date column is populated by the dates from Google Analytics, so the new records will match up with existing data in Salesforce.

  3. You may need to change the dates into a valid date format for Salesforce:: MM/DD/YYYY since Google sometimes formats the dates as YYYYMMDD, and this can cause an import error.

  4. Double check the rest of the file for accuracy and any remaining cleanup issues.

Importing the Google Analytics data CSV into Salesforce

  1. Open a data loading app. I personally like MuleSoft’s Dataloader.io, though there are others as well. API access to Salesforce is required for all of these tools, but if you are using CloudAmp Analytics Dashboards you need to have Enterprise Edition of Salesforce, so that includes API access.

  2. Log into Dataloader.io using your Salesforce credentials

  3. Click on “New Task” on the top left
    Google Analytics Import 12b

  4. Choose the type of job (most likely “insert” for creating new records) and select the object in Salesforce where your Google Analytics data will be store (“CloudAmpGA Metrics” for CloudAmp customers)
    Google Analytics Import 13

  5. Select the CSV file you wish to import.
    Google Analytics Import 14

  6. Check to see that the column headings in your file were properly matched to the Salesforce fields. Unmapped fields will be indicated and give you a chance to select a mapping, or ignore and they will not be imported.
    Google Analytics Import 15

  7. Proceed to run the import. We recommend importing a small test file of 5-10 records initially, in case there are any issues.
    Google Analytics Import 16

  8. When the import has finished, Dataloader will update you as to the number of successes. If there are any errors, click to see what the issue was. You can always update the CSV and run the job again if records did not import due to a formatting issue or other problem.
    Google Analytics Import 17

  9. Spot check some of the imported records for accuracy and completeness. Refresh the appropriate dashboard(s) to see the changes from the imported data

So that is a lot of steps, but once you import data this way into Salesforce a few times, it will become an easier process. Combine that with a tool like CloudAmp Analytics Dashboards which automatically imports the previous day’s Google Analytics data into Salesforce every night, and you will have the best of both worlds.

Questions, or problems not addressed in the tutorial? Let me know in the comments below and I’ll do my best to address them.

Advertisements

Use Case 1: Automating Manual Imports into Salesforce

We’ve talked about the general philosophy of centralizing data in Salesforce, and the advantages and challenges of making your CRM system your analytics platform and “single source of truth.” In this series of short blog posts, we focus on some of the use cases of apps to integrate data into Salesforce, both obvious and surprising.

What do you do if you want to integrate data into Salesforce, but don’t have the budget or IT resources for a data integration platform?

In many cases, someone in marketing is armed with CSV files, and manually imports data into Salesforce on a daily or weekly basis.

excel analytics

After all, Salesforce provides import wizards for Leads, Contacts or Accounts. And for importing data to other objects or custom objects, the Salesforce dataloader (or newer tools like Dataloader.io or Jitterbit) works pretty well.

But what happens if you forget to run the import, or are out sick?

And how much time are you spending preparing the CSV files, doing manual imports on a daily or weekly basis?

A new class of enterprise applications, like those Salesforce apps published by CloudAmp, make it simple to automate the importing of data into Salesforce. These apps also provide the data model (objects and fields) to receive the data, as well as reports and dashboards to display and make sense of the data.

GADashboard-Installation-9

These apps typically use modern webservices APIs, as well as OAUTH, so you can install them and get the automated data imports up and running in just a few clicks. Data is imported directly from the source into Salesforce, with no configuration or data connectors needed. And when data is being synced to Salesforce automatically, you can schedule reports or dashboards to be refreshed and/or emailed just after the import schedule, resulting in reporting that always shows the latest data with no human intervention needed.

For a small monthly subscription you not only save a lot of time, but the quality of your reports and completeness of your data improves as well. So put down those CSV files, and go check out the AppExchange today.

%d bloggers like this: