Expanding Marketo's Integration With Google Analytics

March 24, 2016

Marketo provides marketing automation solutions to simplify gathering, sorting, and organizing contact lists. Marketo RTP integrates natively with Google Analytics.

Marketo’s Integration

This integration allows Marketo to insert specific pieces of data that only Marketo knows, such as the Industry, into Google Analytics as Custom Dimensions that describe the user on the website. The linked method automatically passes in Marketo Real-Time Personalization’s firmographic and personalization data, which can help you understand how different market segments respond to marketing, create better reports, and even set up remarketing with more complete (and accurate) data!

Marketo does a great job explaining how to set up their native integration (there’s even a checklist for Google Tag Manager users!)


We’re not going to go any deeper into their recommended approach except to recommend that you should be taking advantage of this simple integration to connect these two sources together!

Getting More Complicated

In order to do more in-depth analysis, data from both data sources can be combined to give an even better understanding of website-user behavior.  To do so, however, it is necessary for the Google Analytics Client ID (cid) to be inserted into Marketo.  This will provide more flexibility for analysis later on, such as linking multiple sessions and marketing pushes together and incorporating offline sales data into reporting.

Getting the Client ID into Marketo

The first step is to get the Google Analytics ID into Marketo.

Custom Fields allow the storage of arbitrary data in Marketo. Marketo doesn’t use these fields internally, but keeps them with the client record. A Custom Field could be used to store the Google Analytics Client ID so that we can later combine the client record in Marketo and Google Analytics. The Google Analytics Client ID is, itself, an opaque identifier for each device which has accessed your site and does not itself contain any information about the device or visitor.

Depending on how your site is integrated with Marketo, there are different recommended paths to handing the Google Analytics Client ID to Marketo. One method involves custom forms, which require JavaScript on form submit. The other method uses Marketo Forms, which can tie into the callbacks that Marketo Forms provides.

In a custom form, a hidden field with the name of the custom Marketo Field used to contain the Client ID must also be placed in the form. Before submitting the form to Marketo, the Client ID must be extracted from Google Analytics and placed into the hidden form field manually. The following snippet of code is an example of how this may be accomplished (using jQuery).

$("#form-id").submit(function() {
    ga(function(tracker) { 
        var clientId = tracker.get('clientId');

When using Marketo Forms, a similar method can be used to insert the Client ID into a hidden form. (More information on the Marketo Forms API can be found in their documentation.)

MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
        ga(function(tracker) { 
            var clientId = tracker.get('clientId');

Getting the Client ID into Google Analytics

You will need to simply create a new Custom Dimension, for example, “GA Client ID” and follow a similar method to the JavaScript above to grab the Client ID and pass it into Google Analytics when sending a hit, such as a pageview.

How to Combine the Data

Once the Client ID is stored, there is a link between the client record in Marketo and in Google Analytics that we can use in many powerful ways. We are now able to connect specific web visitors on our site with their Marketo profiles, and with some data manipulation begin to derive better insights.

To bring extra metadata into Google Analytics beyond the default Marketo implementation, we can now use the data import feature to export data from Marketo and import the data into Google Analytics, keying off of that Client ID.

With the Client ID stored in Marketo, you can begin to take advantage of the Measurement Protocol, passing hits to Google Analytics that occur offline. Purchases, conversions, or even activities like phone calls can be sent to Google Analytics and, because you now have the ability to pass the correct Client ID with the hit, you’ll connect to that particular user’s previous and future web history.

For instance, you can track customers converting offline and link multiple Google Analytics users to the same lead. By providing a more detailed understanding of how your web presence interacts with the rest of your marketing and sales process, the website can be made to fill it’s actual role in said process better.

Moreover, by linking between tools, revenue from offline sales can be credited back to the online ads that initiated them. By having correct revenue attribution on ads, a clearer picture of which campaigns are effective can be painted.

With Marketo and Google in lockstep, you will find boundless ideas of what can be done with your data, and how leveraging said data can improve marketing and sales ROI.