Posts Tagged ‘salesforce’

Oct 14


Bill Gates once said,

“The most meaningful way to differentiate your company from your competitors, the best way to put distance between you and the crowd is to do an outstanding job with information. How you gather, manage and use information will determine whether you win or lose.”

With the announcement of Wave, SalesForce Analytics Cloud, it’s now more important than ever to measure clients’ 360 journey to connect the dots between business user data (e.g. sales data in SalesForce) and web and mobile behavioral data (e.g. user interactions data in Google Analytics).

In this post, we’re going to show you how to do that!

Our Story

To improve profitability, every company (regardless of size) requires multiple tools to understand their customers and potential customers.

In our organization, we use Google Analytics to improve the effectiveness of our web and mobile presence as well as to track and understand the behavior of our online visitors and how they interact with our digital properties (Website, Mobile App, YouTube Channel, Facebook page, Twitter Profile,…). When our (online) visitors convert to leads, we rely on our CRM platform, SalesForce, to track the history of our prospects’ and customers’ offline and online interactions. We track every single conversation possible – from emails, calls, meetings, and documentations.

While Google Analytics itself gives us the ability to measure the effectiveness of our marketing campaigns in terms of what channels bring visitors to our “front door”, we were missing the link between real live sales conversions and the original (online) lead generation/traffic sources.

Our sales team receives a flood of leads and sales, talking to many prospects and meeting with many customers. We need to link the valuable information they gather with what brought these leads to us in the first place. This missing link led us for many years to inaccurate conversion attribution, bad budget allocation, and incorrect strategic business focus.

Corrective Action

In order to make better-informed decisions on marketing, budget allocation, and strategy, we need to have clear visibility into the sales cycle not only from the point of live contact, but from the possible origin of online inquiry.

To do that, we integrated the two tools that tell us this (SalesForce and Google Analytics) in the following way:

  1. Pass as much relevant Google Analytics visitor behavioral information as possible to SaleForce with every form submission
  2. Pass the final lead status and offline activities from SalesForce back to GA.

Technical Challenge: New integration method with Universal Analytics

Marrying data from different sources is nothing new. But when marriage gets a little stale, sometimes you have to find new ways to spice it up! :) Our legacy solutions were heavily dependent on the Google Analytics _utm cookies that are generated by the classic ga.js tracking code, in which session and campaign information are stored in the tracking cookies.

In the new Universal Google Analytics, all tracking happens at the server-side level and the single _ga cookie generated by the new analytics.js does not contain any session or campaign information.


We adjusted our classic integration method with a solution that works with all GA tracking code versions, including the latest version of Universal Google Analytics tracking code. All needed code was bundled in one JavaScript file called GASalesforce.js

Passing GA data to SalesForce

By following the steps below, you’ll be able to pass users’ campaign and session information into SalesForce every time a form is submitted:

1. Setup SalesForce Custom Fields
Create the following 8 fields in SalesForce:
create custom fields in salesforceWatch this video to learn how to create a custom field in SalesForce.

  • Visitor ID: a unique, persistent, and non-personally identifiable ID string representing a user.
  • Medium: The marketing channel. Possible medium include: “organic”, “cpc”, “referral”, and “email”.
  • Source: The referral origin. Possible sources include: “”, “”, and “direct”.
  • Campaign: Name of the marketing campaign.
  • Content: Additional campaign identifier.
  • Term: The words that users searched.
  • Count of Sessions: The number of visits to our site including the current session.
  • Count of Pageviews: The number of browsed pages prior to the form submission.

2. Add Hidden Fields to Forms
Add the 8 variables created in the previous step as hidden input fields to all forms in your website in which you want to track in Salesforce.

3. Setting Visitor ID
Value of the Visitor ID hidden input field can be read from the backend system (This is the same value that we will use later to set a Google Analytics custom dimension).

4. Setting Campaign and Session Information
The values of the hidden fields can be read from the JavaScript file referenced in step 7. The code will generate GA cookies and parse out the campaign variables from the cookies and make them available in the 7 following variables: source, medium, term, content, campaign, visit_count, and pageview_count.

5. Pass values to hidden fields. Logic should be put in place within the form to pass the values of the hidden fields to their corresponding fields within SalesForce when the form is submitted.

6. Download GASalesforce.js
Download it from here to your local environment.
Download GASalesforce.js

7. Cross Domain Tracking
If cross-domain tracking is needed, update GASalesforce.js with a comma-separated list of domains to set up automatic cross-domain link tracking.


var domains = ["", ""];

8. Reference the GASalesforce.js file.
Placing the following code before the closing tag on every page of the site.

<script src="" type="text/javascript"></script>

9. Make sense of the data!
Now after we successfully collected all campaign and session data in Salesforce, we can make more sense of it and can extract intelligence.



Passing Salesforce Data to GA

In this section, we’ll utilize a really cool new Google Analytics feature called Data Import to pass customers’ lead information from Salesforce into GA. With Data Import, data can be uploaded from different data sources and combined with the existing Google Analytics data to create one powerful and robust unified report.

The “key” that we’re going to use to marry the two data sets will be the Visitor ID. If Google Analytics finds matching keys, it will join the data in that row of imported data with the existing GA data.



Step One: Create Custom Dimensions
Since “Visitor ID” and “Lead Status” don’t exist as dimensions in Google Analytics, you’ll need to create them as a Custom Dimension.

Custom Dimension Name Scope
Visitor Id User
Lead Status User

You must pass your own visitor ID to Google Analytics as a custom dimension to represent each user who submitted one of your forms in question.

When you have a unique, persistent, and non-personally Visitor ID, set it directly on the tracker as in the following example:

ga('set', 'dimension1', 'vid20140930-005');

Step Two: Create the Data Set
1. In Admin, go to the account and web property that you want to upload data.
2. Click Data Import under PROPERTY.
3. Click New Data Set.
4. Select “User Data” as the Type.
5. Name the Data Set: “Lead Status”
6. Pick one or more views in which you want to see this data.
7. Define the Schema:
Key: Custom Dimensions > Visitor ID
Imported Data: Custom Dimensions > Lead Status
Overwrite hit data: Yes
Click Save.

Step Three: Export Salesforce data
Export the lead statues data from Salesforce into a CSV file.


Step Four: Upload the data
1. In the Data Set table, click “Lead Status”. That will display the schema page.

2. Click Get schema. You’ll see something like the following:

CSV header

This is the header you should use as the first line of your uploaded CSV file. The table below identifies the columns:

Visitor ID Lead Status
ga:dimension1 ga:dimension2

3. Update the exported CSV file to follow the below format. The first (header) row of your spreadsheet should use the internal names (e.g. ga:dimension1 instead of Visitor ID). The columns beneath each header cell should include the corresponding data for each header.

The CSV file should look something like this:


4. In the Manage Uploads table, click Choose Action > Upload files. Choose the CSV file you created.


Step Five: Create Custom Report
Since custom dimensions don’t appear in standard reports, create a Custom Report with our two dimensions (Visitor ID and Lead Status) and your desired metrics.

1. Uploaded data needs to be processed before it can show up in reports. Once processing is complete, it may take up to 24 hours before the imported data will begin to be applied to incoming hit data.
2. Data Import also now supports a new Query Time mode that allows linking data with historical GA data. Query Time mode is currently in whitelist release for Premium users.


And now you can analyze the online user behavior of only those who are marked offline as qualified leads.


Wow, this was a long post! But there you have it – very common uses cases for those of us ready to move their marketing optimization a notch up. I welcome your comments and other use cases our readers come across.

Jun 28

*****UPDATED ARTICLE 10/15/2014: Integrate Universal Analytics with SalesForce!

salesforce google analytics integrationYou have several tools and channels: Paid Campaigns (Google Adwords), Google Analytics and Salesforce.  All are robust and tell you different details about the behavior of your leads/prospects.  Google Analytics has an overall view about your visitors (qualified and unqualified leads), while Salesforce has detail about each individual lead.

Until now, these views are looked at separately.  Wouldn’t it be powerful to be able to combine them into one comprehensive full 360 view of your leads?  To be able to find out where they went, how they converted, then optimize for that conversion to get more leads???

The only code for Salesforce integration that existed used to be for Google AdWords.   Even that has since been retired as of May 1, 2013 (read more about it here).

In this post, we hope to provide code that integrates Salesforce and Google Analytics, which not only replaces the Adwords integration, but will work with any of your marketing channels and campaigns.

Why Integrate Salesforce with Google Analytics?

Google Analytics has very rich reporting capabilities for conversion tracking. For example, you can define a goal by simply identifying a unique URL of the thank you page for any form on your website. And if one doesn’t exist, you can even “fake it” by creating virtual pageviews or events. This will allow you to analyze the number of conversions you receive, where they came from, and other user behaviors about visitors who convert.

Salesforce is “the name” in sales funnel reporting. Each time a lead submits information through forms on your website, through integration with Salesforce (or through manual entry from your sales representatives) other information about the leads can be entered and tracked.

But both tools alone might have missing pieces. In Google Analytics, how many of my conversions are spam or unqualified leads? In Salesforce, what information or pages were my leads looking at that got them to convert? Are search engines a primary source of converting traffic? Etc.

Google Analytics and Salesforce each have a place in helping analyze how to improve your sales funnels and the quality and quantity of your leads. Combining the two can really give you powerful insights to act upon.

In this post, we’ll show you how to pass Google Analytics information to Salesforce, then cover advanced integrations, such as passing unique keys that will allow you to tie visitors between Google Analytics and Salesforce. From there, you can get “first touch” campaign information.

Implementation (The Code)

The code below will allow you to improve your reporting by passing the traffic source information into Salesforce every time a form is submitted.

  1. Setup the following 5 fields in Salesforce:
    • Medium
    • Source
    • Campaign
    • Content
    • Term

    Here’s sample code (“xxxxxxx” represents the database id/api name of the custom field, depending on your salesforce mapping):

    <input type="hidden" name="txt_medium" id="xxxxxxx" value="" />
    <input type="hidden" name="txt_source" id="xxxxxxx" value="" />
    <input type="hidden" name="txt_campaign_name" id="xxxxxxx" value="" />
    <input type="hidden" name="txt_term" id="xxxxxxx" value="" />
    <input type="hidden" name="txt_content" id="xxxxxxx" value="" />
  2. Update all forms to contain the same 5 fields created in step 1 (they should be hidden so they aren’t shown to the user).
  3. Values for the hidden fields can be read from the GA cookie __utmz. The code below will parse out the campaign variables from the GA cookies and make them available in 5 variables.
  4. Logic should be put in place within the form to pass the values of the hidden fields to their corresponding fields within Salesforce when the form is submitted.
  5. Place the following code on every page on your website that has a Salesforce form before the closing </body> tag.
<script type="text/javascript">
var z = _uGC(document.cookie, '__utmz=', ';');
var source = _uGC(z, 'utmcsr=', '|');
var medium = _uGC(z, 'utmcmd=', '|');
var term = _uGC(z, 'utmctr=', '|');
var content = _uGC(z, 'utmcct=', '|');
var campaign = _uGC(z, 'utmccn=', '|');
var gclid = _uGC(z, 'utmgclid=', '|');
if (gclid !="-") {
 source = 'google';
 medium = 'cpc';

var csegment = _uGC(document.cookie, '__utmv=', ';');
if (csegment != '-') {
 var csegmentex = /[1-9]*?\.(.*)/;
 csegment = csegment.match(csegmentex);
 csegment = csegment[1];

} else {
 csegment = '';

function _uGC(l,n,s)
if (!l || l=="" || !n || n=="" || !s || s=="") return "-";
var i,i2,i3,c="-";
if (i > -1) {
i2=l.indexOf(s,i); if (i2 < 0){ i2=l.length; }
return c;

document.getElementById("txt_medium").value =medium; /* Campaign_Medium */
document.getElementById("txt_source").value =source; /* Campaign_Source */
document.getElementById("txt_campaign_name").value =campaign; /* Campaign_CampaignName */
document.getElementById("txt_term").value =term; /* Campaign_Term */
document.getElementById("txt_content").value =content; /* Campaign_Content */


After implementing this code you can test one of the forms on your site and this is what you should see in Salesforce:

Salesforce Google Analytics Fields


Congratulations! You are now pulling reports in Salesforce and accurately determine what traffic sources are resulting in opportunities, qualified leads, and customers.  Now you have a more accurate understanding of the true ROI of your marketing activities.

(Keep in mind that when testing to clear your cache, cause any previous cookies or tags associated with your site will reflect in the form submission.)

The following is a report we have helped many of our customers work towards, which is mapping their Salesforce lead/customer data to their advertising spend.  This report shows the ROI and cost per qualified lead for each of their marketing channels.

salesforce google analytics marketing dashboard

A Note About Autotagging/AdWords

If you are trying to analyze the impact of your AdWords campaigns, you may notice that in Salesforce all of the Keywords, Content, and Campaign information is missing. This will happen if you have AdWords set to use autotagging. If this is the case, the default implementation provided above will not be able to pass anything more detailed, because the AdWords information is hidden in the GCLID, which is not decoded until later in Google Analytics.

If this information is important you have two options:

  • You can disable autotagging and use manual tagging
  • You can customize our code to accept customer parameters, which you can append to all of your destination URLS.

Advanced Implementations

Qualified Lead Behavior in Google Analytics
Marketers, get ready to have your mind blown! The number one question every business has is, “How can we get more business?” One of the keys to answering this question is to understand the common traits of your buyers. “How did we close you?” so we can do more of that.

With this integration, by associating a unique identifier with visitors in Google Analytics and passing that info to Salesforce, you can easily filter for this unique identifier (if you have goals set up) by using their built-in advanced segment of converting visits. What does that mean? That’s right, you’ll be able to see what your qualified leads did on your site!

But if your conversion is a form submission or contact email for example, what you cannot do though is create a segment of only your qualified leads or actual customers, as it will likely be filled with spam leads and non-qualified leads. We can solve this with a bit of code.

Our friend Justin Cutroni details in his blog post here how to store the unique ID that Google Analytics generates into a custom variable.  By reading the __utma cookie, we can extract this ID and send it to Google Analytics and also send this key into Salesforce. By placing this code on all Salesforce form pages on your site and passing it into both Google Analytics and Salesforce we will now have a key between the two systems to tie visitors together!

Now, in Salesforce you can create reports of qualified leads, customers, or any other customer grouping and extract these unique ID’s, then take these unique ID’s and create advanced segments for each of these groupings like so:

salesforce leads field custom variable

google analytics advanced segment custom variables

First Touch Attribution
Almost every Google Analytics report (except for Multichannel Funnels) is built on a last touch attribution model. Meaning, when you create reports or segments for converting elements, only the last traffic source is being tied to it. This is the same for our Salesforce / Google Analytics implementation that is provided above.

If you need insight on first touch campaigns and marketing channels, with some minor modifications, you can pass this along. Conceptually, this works best when you pass and store this information from the Google Analytics cookies into your database. Every time, that user re-authenticates and fills out a form, you can read this information from your backend and pass it into Salesforce using hidden fields.

Conclusion: 360 Customer View

The integrations mentioned above allow you to get closer to a 360 view of all of your customers and leads. By passing your visitors campaign and marketing channel information from Google Analytics into Salesforce, you will be able to report on the ROI and Cost Per Qualified Lead, which are two metrics every lead oriented business should have. By using the advanced implementations you can pass more information into Salesforce and create segments of your visitors based on information that is learned from them in Salesforce.

We have done many custom implementations of Salesforce and Google Analytics and with marrying both systems to other data sources.  The true power in it is architecting a solution that meets your needs. Feel free to contact me at: if you have any questions or would like help working out a solution for your environment.

May 22

Introducing Google Big Query

Cloud Computing
With Google BigQuery publicly available, all businesses can combine large data sets with amazing speed and do analytics in the cloud.

What Kinds of Questions Can You Answer With Google BigQuery?

Let’s say you are the marketing manager of a large B2C business that is driving traffic to your site through many channels including paid search, affiliates, email, and some offline campaigns as well. You really want to tie the campaign cost data all the way to your qualified leads, opportunities, and sales data, which typically resides in a CRM system, such as SalesForce, SugarCRM, or the like.

But why stop there? You also want to throw in your web analytics data and get engagement metrics in the mix. Last but not least, you’ve done your homework and implemented an integration strategy to tie all this data together (e.g. using a primary key).

You want to produce a very actionable report that shows:

  • Campaign cost data
  • Web analytics data
  • CRM data
  • A super actionable metric cost per qualified lead, broken down by campaign!
Cost per Qualified Lead Calculation with Google BigQuery

Report Analysis

In the above report, the cost per qualified lead for the Software Demo campaign in Google Adwords was just a little bit over $30, and you can start trending and optimizing accordingly. Run experiments and gather user feedback to bring that cost down!

Other Useful Features

  • Metrics like cost per qualified lead can be recalculated with amazing speed as often as the data is refreshed.
  • Results like this can be saved as a table, allowing you to build up layers of useful reports and then combine them to build even more useful reports.
  • Reports can be downloaded in CSV format for integration with Excel, PowerPoint, or whatever presentation and integration tools your business might use.
  • Unsampled reports from large data sets in Google Analytics Premium are the perfect kind of data set to upload to Google BigQuery.

Technical Details about Google BigQuery

  • Google BigQuery is a tool which allows businesses to gain insights from large data sets without any initial hardware purchases or software investments.
  • The BigQuery service is an online analytical processing (OLAP) system designed for terabyte-scale datasets.
  • The service supports SQL-like queries against those massive datasets.
  • BigQuery is surprisingly developer friendly, as it supports the straight forward REST (REpresentational State Transfer) Web service for pushing data to Google’s cloud and then querying it.
  • Google BigQuery can be accessed through a web tool or programmatically through the REST interface.
  • The web tool might be useful in visually identifying relationship and building queries, while the REST interface lets your developers get at the data in the most efficient way.

What Are the Possibilities?

Contact E-Nor for more information on how we can help you leverage Google BigQuery to answer business questions and improve your bottom line.

Feb 25

Integrating lead information from one system such as Google Adwords into a CRM like Salesforce is definitely not a new topic, especially since the Salesforce-Google Adwords integration has been announced for a while now.

I want to highlight the steps required for a seamless integration, as well as a few additional pro-active steps you want to take to keep your Google Analytics data clean. The same concept would apply to other analytics tools you might be running. As Avinash always reminds us, data accuracy is always one of the biggest challenges in web analytics.

Here are my steps:

  1. Create Adwords and Salesforce accounts.
  2. Link Google AdWords with Salesforce.
  3. Exclude SalesForce parameters from Google Analytics.
  4. Set up AdWords lead tracking.
  5. View report.

1) Create Adwords and Salesforce accounts

You need to have a Google AdWords account and a Salesforce account before you can integrate them.

2) Link Google AdWords with Salesforce

  • In Salesforce, click the Google AdWords Setup tab.

  • Enter your AdWords customer ID and login e-mail.

3) Exclude SalesForce Parameters from Google Analytics

When Salesforce performs its integration with AdWords, it appends parameters (_kk and _kt) to all destination URLs in your AdWords account. We suggest that you strip these query parameters out of URL to insure no duplicate entries in your Top Content report.

To strip the query parameters, please follow these steps:

*A note for AdWords managers. Keep in mind that when Salesforce appends the destination URLs with its _kk parameters, this is actually “editing” your AdWords ads and the stats associated with these ads will now reset, according to how Google AdWords works.

4) Set up AdWords Lead Tracking

  1. Back in SalesForce, click on the Google AdWords Setup tab.
  2. Click on the “Set up Lead Tracking” button.

i – Create a Web-to-Lead Form

  • Click on the “Create Web-to-Lead Form” button

  • Add the form to your page
<META HTTP-EQUIV="Content-type" CONTENT="text/html;
<form action="
encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="xxxxxxxxxxxxxxx">

<input type=hidden name="retURL"

<label for="first_name">First Name</label><input id="first_name"
maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input id="last_name"
maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input id="email" maxlength="80"
name="email" size="20" type="text" /><br>

<input type="submit" name="submit">

ii – Add the Salesforce Tracking Code to the Website

Typescript,Computer Graphic,Text,Single Word,Article,Newspaper Headline,Information Medium,Newspaper,Printed Media,Print Media,The Media,Folded,Report,Business,Finance,Banking,Document,Paper,Printing Out,Printout,Print

Add the following tracking code to every page of your site right before the </BODY> tag

<!-- Begin Salesforce Tracking Code -->
<SCRIPT type="text/javascript" src="">
<SCRIPT type="text/javascript">__sfga();</SCRIPT>
<!-- End Salesforce Tracking Code -->

iii – Test Your SalesForce installation

By clicking the “Test your Setup” you will be able to test the installation of the codes in step i and ii

5) View report

This report gives an overview of the leads submitted to SalesForce from your website

For more detailed information, click on each lead and learn more about the lead source