UPDATED: Integrating Google Analytics with a CRM

A while back I wrote a post about how you can integrate Google Analytics with a CRM system. That posts referenced the old urchin.js code and is in need of an update. Plus a lot of people have been asking me about different integration options and I thought it would be a good time to revisit the topic.

So here it is, an update. I’m not going to re-do the entire post, just a few key points.

Why Do This?

This entire hack configuration is based on one simple idea: to build a more robust view of customers/prospects/leads/whatever-you-call-them. The more information we know about people that we sell to the more we can adjust our marketing. This technique let’s us combine where the visitor came from (referral, campaign, direct, search engine) and how often they’ve been to the site with CRM data.

How It Works

We’re going to extract data from the GA tracking cookies and add it to a lead generation form. The GA data will be stored in hidden form elements that the visitor can not see. When the visitor submits the form the GA will be connected to the other information that the visitor entered into the form (usually name, contact information, etc.).

Adding GA data to a CRM

Here’s the data that we’re going to pull from the GA cookies:

* Current referral information (i.e. where the visitor came from)
* Custom segment value (if it exists)
* How many times the visitor has been to the site

You’re probably wondering why we’re not extracting the data via the GA API. More on that in a minute.

The Code

Here it is, the updated code:

The new code differs from the original code in three ways:

First, the inclusion of ga.js. No explanation needed there.

The second change is the addition of the _uGC() function. This function was in the original urchin.js, and because I don’t include that file I need to include the code in the script.

The function is used to parse pieces of data and return certain parts. For example, I use to to parse the cookies (which are just a string) and return the value of the campaign cookie (__utmz), the custom segment cookie (_utmv) and the visitor identification cookie (__utma).

Finally, I added some new functionality to include this visitor’s number of visits. This data is pulled from the __utma cookie (which identifies the visitor). The last integer in __utma is actually a visit counter. I think it is interesting to understand behavior based on frequency so I added this nugget of data.

If you want to see the code in action try this:

In my previous post I included a reference section that documents the format of the campaign cookie and the _uGC() function. Check it out if you’re looking for more technical information.

An Alternate Approach

Remember, all the data we’re pulling is in first party cookies. This means that you could extract the info at the server level rather than the browser level (first party cookies are available to server side code).

You don’t need to do this in JavaScript, as I did. You could use ColdFusion, PHP, .NET or some other server side language.

I’m just trying to provide some inspiration here :)

What About the Google Analytics API?

I’m sure there are a lot of people out there wondering about the GA API and why I don’t just use it to pull data out from GA. The reason is the data in GA is all anonymous, aggregated data. There’s no way to reach into GA and say, “tell me where John Doe came from.” That’s why we pull data from the cookie, because we can combine it with a visitor’s info when they supply it.

Sure, it is possible to pull out GA data and place it in a CRM (like traffic from an email campaign, bounce rate from paid search, etc.) but it’s tough to identify individuals in that data.

Is it impossible? No, not from a technical standpoint. You would need to place a unique identifier in GA to link the data.

But we’re getting into a risky area here.

Remember, it is against the GA terms of service to capture data in GA that identifies an individual. This could be an email address or database ID number. Not my rule, Google’s, and they will crack down.

I’d be interested to hear people’s thoughts on this. Feel free to comment!

Adding Business Data to Google Analytics Data

I know the past week has been full of Google Analytics news, but I’m excited to tell you about something one of our team members created: Google Analytics Notes.

For a long time we’ve wanted to add business data to GA to help keep track of marketing activities, industry news and GA configuration changes. These things are critical to know when analyzing data as they add more context and help us understand what’s affecting website performance.

We tried using Google Spreadsheets to store business info but it never worked. People did not take the time to open up a spreadsheet and add information. We figured that adding some type of ‘note’ functionality to GA would be the easiest way to change this behavior. That’s how GA Notes was born.

GA Notes is a Firefox extension that lets you add business data to a profile. Notes appear in a concealable table at the top of every report.

Any GA user who views a profile, and has the Firefox extension, will see the notes entered for the profile. You can add notes, edit notes and delete notes. Notes can also be exported in XML format for archival purposes.

Installation

Installing GA Notes is easy. Just download the following file to your computer:

https://ga-notes.appspot.com/ganotes.xpi

Once downloaded double click on the file. Firefox should open and ask if you want to install the extension. Click install and that’s it. You’re ready to start adding notes to your GA data.

Usage

The extension adds a ‘Show Notes’ button in the GA menu bar. Click on the button to view notes for this profile or to add a note or edit/delete an existing note. It’s not that complicated. :) We wanted to keep this easy and flexible.

How it Works

For those of you that are interested, GA Notes runs on Google’s App Engine. No data is stored on your machine or our servers. It’s stored on Google’s servers. The Firefox extension provides the interface to enter and display data. But all of the processing and data storage happens on App Engine. All data sent to App Engine is encrypted prior to transmission.

In a perfect world we would have added notes to the data-over-time graph at the top of each report. However, we can’t get inside that part of GA using a Firefox extensions (or Greasemonkey script). We thought this was a good compromise. If anyone out there knows how to dig into Flash let us know! :)

Road Map

This is obviously a beta version of the software. We have a number of features that we’re working on and hope to have done soon. These include:

  • Sorting and searching notes by date
  • Excel friendly export
  • An admin flag for notes to separate admin changes to your GA account
  • Some type of alert to show you how many new notes have been added since your last login
  • A more graphical visualization of note

If you have any suggestions or ideas please let us know!

Credit

I don’t have the smarts to build these types of things, I just know enough to be dangerous. Chris, a new member of our team, built GA Notes from the ground up. Thanks Chris for all the hard work.