fb-share
Contact Us menu-bars menu-close

Analyzing Salesforce data with Google Analytics: Part 1

avatar

Arun Kumar Bharati

June 15, 2015

As a Sales Rep or a Strategic Account Manager, I am sure you have felt the need to understand who are your most popular Customers or Opportunities. This information is invaluable and opens up a heap of avenues which can be leveraged to build a better strategy in nurturing the relationship with them, thus resulting in a mutually rewarding situation. In this blog series, I will help you track your most popular Accounts based on page views and hence get a little more out of your Salesforce CRM. We would leverage Google Analytics in conjunction with your Salesforce org to accomplish our goal. However, before we jump hoops, I will first demonstrate how to configure your Google account and Salesforce orgs for achieving the same. In this first part, I will explain the configurations you need to make to your Google account, while subsequent posts will explain the configurations you need to make to your Salesforce org to track your most popular accounts.

Prerequisite: a Google Analytics account

Before we begin, you need to create a new free Google Analytics account. Visit http://www.google.com/analytics/  for the same. You can also use an existing analytics account, if you have one.

Analyzing Salesforce data with Google Analytics

Setting up a property in the Google Analytics account

Once your Google Analytics account is ready, you need to create a new Property to generate a Google Analytics tracking ID and tracking code.
You will need to specify a Property Name and Default URL for the property.Make sure you use the https:// protocol for your URL. The URL should be in the same format as your Salesforce login URL i.e. https://{yourServerName}.salesforce.com

Creating a New Property

To create a new property, simply follow the steps given below:
  1. Go to the Google Analytics Admin section and click on Create new property.
    Analyzing Salesforce data with Google Analytics
  2. Once you click on Create new property, a property settings page opens. Fill the required details as shown below
    Analyzing Salesforce data with Google Analytics
  3. Once you click on Get Tracking ID, you will be redirected to the Tracking Info page where you will get your Tracking ID in the UA-xxxxxxxx-X format along with the Tracking Code script.Analyzing Salesforce data with Google Analytics
We are going to use this tracking ID and code in our Salesforce org or site.

Creating a Salesforce Account

In the highly unlikely scenario that you do not have a Salesforce developer org already, you can create a new one by visiting https://developer.salesforce.com/signup

Creating a Static Resource File

  1. For creating a Static Resource file, we need to create a JavaScript file with the generated Google Analytics tracking code and tracking ID. This file will be uploaded as a Static Resource on your Salesforce org.Once you have uploaded it on your Salesforce org, you can reference it as and when you need it through a custom home page narrow sidebar component, which I will show in subsequent sections of the blog.
  2. Copy and paste the JavaScript code given below on a file on your local machine named GoogleAnalytics.js. 
  3. Replace the tracking ID UA-xxxxxxxx-X on line 7 with your Google Analytics tracking ID. Remember to exclude your JavaScript start and end tags, i.e. <script> or </script>.
    Analyzing Salesforce data with Google Analytics
  4. Upload the GoogleAnalytics.js file to Salesforce
    by going to Setup | Build | Develop | Static Resources
    Analyzing Salesforce data with Google Analytics
    • Click on the New button
    • Name the static resource as GoogleAnalytics
    • Click Browse and select the JavaScript file that you created recently
    • Set Cache Control to PublicAnalyzing Salesforce data with Google Analytics
  1. Click on SaveSalesforce has a limitation that Custom Link Home Page components do not have access to the $Resource merge fields, so you need to know the actual URL of the JavaScript file that you uploaded (for more information on this, see https://success.salesforce.com/ideaView?id=08730000000KRuxAAG).
  2. Click on View file on the Static Resource page and copy the relative path from the browser (it would be in a format like: /resource/1428508522000/GoogleAnalytics.js). The numerical part in the URL is actually a date timestamp that Salesforce uses for caching purposes.
    Analyzing Salesforce data with Google Analytics

Note: If you want to see the JavaScript file and the relative path URL, you simply need to click on View file.

In the next part of this blog, I will explain the required configuration that you need to do to your Salesforce org, which includes creating home page custom link and component, adding the component to the home page layout and showing the custom sidebar components on all the pages. Till then, keep your Google Analytics account ready!

Get updates. Sign up for our newsletter.

contact-bg

Let's explore how we can create WOW for you!