Accessing your Google Analytics data

5
(3)

I run a blog, which since you found this particular blog you, of course, know that, and like many others that run blogs or websites, I too have added a Google Analytics script to my blog. To be honest I’ve never really looked at the Google Analytics data since counting hits and other metrics hasn’t been a driver. That being said lately I’ve had some questions that made me decide to pull my Google Analytics data to Einstein Analytics (of course) using the out of the box connector guided by the official documentation. In this blog, I’ll explain the steps I had to complete in Google Analytics as well as Einstein Analytics to get access to the data.

Setting up credentials for Google Analytics

If you have worked with the Einstein Analytics connectors before, you probably know they are easy to set up, however, there is often work to be done in the source system prior to setting up the connector. It is not any different with Google Analytics.

We first need to navigate to the Google Cloud Platform console – https://cloud.google.com/ as it is here we can set up a service account to get access to Google Analytics via the connector. In the top right, you’ll find a link to go to the console.

Creating a project

If you don’t already have a project in Google Cloud Platform to use you need to create this first. It’s pretty straightforward. In the top blue bar, you can click to get a project view and create a new project from here.

In the dialog box, click on “New Project” in the top right corner. All you have to do is give your project a name and optionally choose a different location followed by saving your new project.

Creating the Service Account

Now that we have the project we can create the service account. Once you are in the console hit the three lines in the top left corner to show the menu and select “IAM & Admin” followed by “Service Account”.

Next, we click the “+ Service Account” to create the service account we need for the connector.

In the new window you just need to give your Service Account a name – I called mine SalesforceBloggerDemo. You can also decide to add a description, which can be helpful if you have multiple Service Accounts for different purposes. Once done just hit the “Create” button. You have the option in the following steps to grant access to projects and users – I’ve chosen to skip this step as it’s not needed for what we are doing.

While the Service Account has been created now we need to generate a key that will give us a client email and private key, which we need to use later. To generate this key in the action column with the three dots choose “Create Key”. We are gonna key JSON as the key type and can click “Create” right away. Note that this will start a download of a JSON file with all the keys. You must save this file as the key cannot be retrieved if lost.

Enable the Google Analytics API

While we are in the project we need to make sure the project and Service Account have the Google Analytics API enabled. Without this API we cannot access Google Analytics in Einstein Analytics.

In order to enable the API we need to go back to the menu and select “APIs & Services” followed by “Library”.

Once you are on the Library page you can search for existing APIs to use in your project. The one we want is the “Google Analytics API”; all you have to do is search for the API and select it. Once selected make sure to enable the API as shown below.

Giving access to the Service Account

We have now set up the Service Account that we need to get access, but at this stage, it isn’t allowed to grab any data from Google Analytics. In order to get access we need to open the JSON file we downloaded before with all the keys, find the client_email and copy the value that is in the form of an email.

Next, move to Google Analytics and head to the admin section. Here we need to add the client email as a user with “Read & Analyse” access. To add the user click on the “Account User Management”.

Next, click on the blue plus button in the top right and choose “Add users”.

All you have to do is add the service email to the email address section and optionally uncheck the notification. You can keep the default permissions “Read & Analysis” and just hit the “Add” button.

Finding the view id

When we set up the connector in Einstein Analytics we need the view id, which you can find in the admin section under the View Settings.

Make sure to copy and save the view id as you will need it later.

Setting up the Google Analytics connector

All the pre-work in Google Analytics has been done and we can now head to the Data Manager and the Connect page in Einstein Analytics.

Once on the Connect page click the blue “Connect to Data” button in the top right corner of the page. Select “Add Connector”, then find and choose “Google Analytics”.

It’s now all the keys and ids come in play. Give your connector a name, developer name, and description. I like to add the view id in the description, so I don’t always have to go look for it in Google Analytics when I want to connect a new object since the view id is needed every time we include a new virtual object from Google Analytics.

Next, add the client email from the JSON file before. We also need to add the private key; when you look in the JSON file it’s the very long string after —–BEGIN PRIVATE KEY—–\n and before \n—–END PRIVATE KEY—–\n

Once added hit the “Save & Test” button. Hopefully, it’s successful and you can now add a virtual object to be synced to Einstein Analytics.

Adding a virtual object

Once the connector has been set up, it is possible to select it from the connector overview. Like with any connectors you first have to select the object you want to connect to and pick the fields.

Clicking next you need to select the start date and the end date for the data you want to bring in. The format is yyyy-MM-dd or you can use a relative term like “today” – to see the full list of patterns and relative terms check this link out under start-date and end-date. Finally, you need to add the view id we looked up in Google Analytics.

Make sure to check if your measures exceed 18 characters, if they do you would need to change it as Einstein Analytics have a limit of 18 characters. You will see a warning in the measure column during the preview if there are any issues.

Once you have gone through the steps and added the objects make sure to set up a schedule to have data ready to use in a recipe or dataflow.

When you are connecting the objects I can recommend checking out the Google Analytics Dimensions & Metric Explorer to understand what fields are available. The Global Access Object is not available in the tool as it is generated by Einstein Analytics. Regardless be aware there is a restriction on how many dimensions and measures Google Analytics allow you to bring over.

Limitations

When working with the connector make sure to check out the consideration section in the Salesforce Help for the Google Analytics Connector. There are some general considerations for all connectors like 100 connected objects, but additionally, make sure to understand the limitations specific to Google Analytics including:

  • The connector can sync 10 million rows or 5 GB per object, whichever limit it reaches first.
  • Google Analytics can sync up to 1 million records the rest will be grouped and marked as other by Einstein Analytics. Consider looking at a limited timeframe such as a day and use the dataflow to append newly synced data with the exciting dataset.
  • You need to choose at least one measure for any object you want to sync.
  • You can maximum connect 7 dimensions and 10 measures for each object.

How useful was this post?

Click on a star to rate useful the post is!

Written by


10 thoughts on “Accessing your Google Analytics data”

  • 1
    Marta on August 13, 2020 Reply

    Hi Rikke!!! I configured GA connector a year ago and I didn’t config GC. And I could access the GA objects. Why did you configured GC (project, account etc)?

    • 2
      Rikke on August 13, 2020 Reply

      If you already have a service account for GA you don’t need to set up a new one. In my case when I recently set it up for my own GA I had never really looked at the data and definitely never configured anything in it, so I was starting from scratch.

  • 3
    Marta on August 13, 2020 Reply

    Ok! But I still don’t understand why t’he Google cloud configuration. I only need Google analytics config.

  • 4
    Jeeson Jolly on November 3, 2020 Reply

    Hi Rikke, Thanks for your article, it’s really helpful. I was able to connect to GA but to be clear, it’s not possible to create a historic graph(metrices shown with date time on the X axis) from the data obtained from the connection right??

  • 5
    Salesforce_20 on January 19, 2021 Reply

    Hi , I do not have the view column in my google analytics. How do i connect my analytics without view id to salesforce

  • 6
    Mark Deguisne on March 24, 2021 Reply

    Hi Rikke,

    Thank you for this information. It is extremely helpful in setting up the GA Connector with Salesforce. The only part I am stumped on is that within Tableau CRM in our org, when I navigate to the “Connect to Data’ section I am not given the option for any external connectors. We have a B2BMA integration, and the Data Sync checkbox is enabled for our org. Any thoughts? Are there limitations on which connectors are available possibly depending on what kind of subscription we have?

    • 7
      Rikke on March 24, 2021 Reply

      I believe in this case it’s to do with your license. I don’t think B2BMA allow you to use connectors.

  • 8
    Yancey on September 24, 2021 Reply

    For custom dimensions, the API seems to require the request to be ga:gdimension1 or ga:gdimension2 however it seems that Salesforce sends the request as ga:dimension01. How can I solve this?

  • 9
    Paula on December 3, 2021 Reply

    Thank you for this information. It is extremely helpful. You made my day. I have a problem with data format ga_date to a Date format (yyyy-MM-dd, for example). GA_date is yyyymmdd. In your videos I see you had the same problem. How did you solve it?
    Thank in advance

  • 10
    Kiel on August 10, 2022 Reply

    Will you update this guide on how we can switch to a GA4 stream / connection in the future?

Leave a Reply to Marta Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.