Back to the Learning Center

By: Casey Grimes on May 25th, 2016

Marketo and Google Analytics Integration Guide: Content Grouping

We’ve arrived at part four of our five-part Marketo and Google Analytics Integration Guide series. First, a note: many of the examples we’ll be showing here presume that you have gone through the steps to associate Marketo User IDs with both your Google Analytics UID and as a Custom Dimension, as explained in the Ultimate Google Analytics and Marketo Guide. If you have not done this, these examples will fail to work properly!

Read the other five parts in this series to get a cohesive picture of the integration process:

Our disclaimer from Part 3 applies here: while these are examples, they are likely not what you should do verbatim. Instead, use them as a starting point to make Google Analytics work effectively, aligning it with your company’s needs and expectations. With that said, let’s dive in!

Content Groups

In Part 3, we talked about the idea of Channel Grouping: splitting and organizing your incoming traffic based on your unique traffic sources. This same concept can actually be applied to your content as well!

Content Groups allow for various web pages to be categorized together in order to analyze them as a whole. This is especially important for instances where your URL structure might make things difficult to group together—for example, if you’re running a blog but don’t have the word “blog” in your URLs. The concept becomes even more useful when marrying data together across different subdomains and structures, such as your corporate website and your Marketo landing pages. Which works better, squeeze pages out of Marketo or from your info-laden corporate web pages? Group them together and find out!

If you want to compare what blog entries have been performing the best over a certain time period, simply run a Content Group report to get that comparative data in one place.

(Awww, you guys like the content I write the most!)

To set up Content Groups and the rules for grouping pages together, simply head to Admin -> View -> Content Grouping. You can use URL strings, regular expressions and custom data rules, among others, to bring different pages together. From here, you can pull in your Content Groups as second dimension to enhance any Google Analytics report.

Custom Dimensions for Tagging Content

While Content Groups are great for seeing your different content types in aggregate, what if you want to do the reverse and figure out what types of pages an individual is interested in? Do they show any interest beyond what we can learn from a Visited Web Page hit?

As an example, we post Coffee Break Reading article collections most Fridays—but what if we have a prospect who is only interested in Coffee Break posts about content strategy? We’d never know that from just a URL. Knowing this information can help steer the conversation with the prospect towards content strategy and make DemandLab more relevant. The answer: Custom Dimensions.

If you followed Part 2 of this guide, you actually set up your first Custom Dimension—your Marketo ID should be set as a Custom Dimension in addition to setting it as the Google Analytics User ID.

But first, let’s take a step back: What’s a dimension and a metric? Simply put, dimensions measure characteristics of users, the sessions they’re having, and their actions, whereas metrics measure quantifiable actions that have been taken. For example, which browser a user is using would be a dimension; the number of pages they looked at with that browser would be a metric. (Still confused? Analytics Academy has a great video explaining the concept of dimensions and metrics in more detail. In fact, if you haven’t gone through Analytics Academy, you should—it will make a lot of what’s talked about in these articles make more sense.)

In this example, you’re going to use tags as a Custom Dimension, but the method you’ll use to apply Custom Dimensions will differ based on your current implementation of Google Analytics. If you are using Google Tag Manager, you really should push your Custom Dimensions as a data layer and alter your Google Analytics tag’s firing accordingly. If you’re using Google Analytics without Google Tag Manager, you’ll use a structure similar to this in your tracking code:

As a quick refresher, you can add Custom Dimensions by visiting Admin -> Property -> Custom Definitions -> Custom Dimensions in Google Analytics and click “+New Custom Dimension”. In this particular case, something like blog tags would be unique to each page being visited, so you’re going to want a scope of hit as opposed to session or user.

Also note that you will likely need to work with your web development team in order to properly echo your tags either into the data layer or into your tracking code, and execution will depend on your web language. The result will look something like this:

This data becomes especially useful when sending data back to Marketo, as you can begin to create interest scoring around the content that visitors consume without being beholden to a URL structure.

Basic Events: An Expanded Concept of Interesting Moments

Events are Google Analytics’ way of tracking notable interactions a user has with your website—clicking on a link, watching a video, sharing a link on social media, filling out a form, or interacting with Flash. The only limit is your imagination! Events are also stored separately from web activity, so they serve as a quick way to compare and contrast web activity. For instance, Events can show what actions a user took on your website before filling out a form or if time on site affects conversion events.

However, one way that I find Events to be really useful for Marketo users is to use Events to bridge the gap between Marketo’s limited web reporting and the important individual Moments that happen to a user—as such, I’m a fan of bringing Marketo’s Interesting Moments into Google Analytics to understand what’s causing those conversions. With Marketo’s Interesting Moments, your Moments are broken down into three main categories: Email, Milestone and Web.

Google Analytics has a similar sorting system, with Event Category, Event Action and Event Label. Unlike Marketo, though, these are all completely custom fields—you’re free to populate whatever content you’d like in each. Generally, however, I recommend that you use the three fields to sort from most generic (Event Category) to most specific (Event Label).

Moreover, Google Analytics offers a view that Marketo cannot easily reproduce: seeing Interesting Moments in aggregate and being able to see the most prolific moments across your marketing efforts. Echoing what Interesting Moments you’re recording in Marketo in Google Analytics makes sense—and is pretty easily achievable with a very basic Marketo webhook.

We’re going to set up an incredibly basic webhook that will use your Smart Campaign’s name as an Event Action and its description as an Event Label. Inside of your Marketo instance, head to Admin->Webhooks. Since you’re going to be using the Measurement Protocol to write this external data into Google Analytics, you’ll need a unique string to let Google Analytics know this is the particular user adding this data to your database. Since Google uses the UUIDv4 protocol to determine what a unique string is, we’re going to need to generate a random UUID value. Visit the Online UUID Generator and copy the value it randomly generates under “Your Version 4 UUID.” From there, click New Webhook and fill out the form that pops up with the following:

Webhook Name: Analytics Interesting Moments
URL: http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-X&cid=YOUR-UUID-HERE&aip=1&ds=Marketo&uid={{lead.id}}&t=event&ec=Interesting%20Moment&ea={{campaign.name}}&el={{campaign.description}}
Request Type: POST

Leave everything else blank or as the default value and hit Save.

To use this webhook, simply name your Smart Campaign with the desired name of the Event Action (bearing in mind that if your Smart Campaign is in a program, you will see the full campaign name as Program Name.Campaign Name) and give your Smart Campaign the description you’d like the Event Label to be. Then simply set up your flow to use these labels in conjunction by structuring your actions using the following image as an example.

This will result in your Google Analytics instance recording each event, like so:

This same idea of aggregate counting can be used in a lot of different ways beyond this example, and when tied with your User ID reference, can provide some extremely powerful aggregate reporting that Marketo currently lacks.

This data becomes especially useful when sending data back to Marketo, as you can begin to create interest scoring around the content that visitors consume without being beholden to a URL structure.

Advanced Events: Debugging Forms

While using Events as Interesting Moments is a perfectly valid use of Events, it only scratches the surface of what’s possible with Event recording—and what assumptions you can make from events you record.

As an example, one of the questions I get asked a lot as a digital marketer is how long a form should be. Some schools of thought say that you should get a bare minimum, and others say that only qualified leads will bother to answer all your questions (and so you should have long forms). Like so many things in marketing, there’s no real “best practice” but what works best for you. The trick is to understand what actually works, though, and Events can help us figure that out.

A few years back I was presented with an interesting problem: a company had an event application form on their site, and while both the event and the page the form was hosted on were popular and drove a lot of phone activity, there were a lot less people filling out the application form on the site—which would have required less effort than calling! We tried talking to people who had called in to figure out why they didn’t just fill out the form, but there was no consistent answer they gave. Moreover, seeing the bounce rates on that page, something was happening that made people not want to fill out the form. But what?

In order to solve the issue, I set up Events to record every time a person filled out a form field—the idea being, if you can track cart abandonment in ecommerce situations, why not track “form abandonment”? Once this system was set up, it became clear that the main problem was an open text field asking people to describe an aspect of themselves in detail. Even though the field was optional, its presence caused people to stop—and consequently, not convert. The field was removed and conversions doubled.

Applying this tactic to your Marketo forms is a straightforward process and something you can implement to figure out your completion rates for each field (and overall conversions). The answer is in a small piece of JavaScript, which I’ve shared here. Upon implementation, you can see by Event hit how much of your form is being filled out.

In this example, clearly people are stopping after First Name.

Bring it on home: Taking data from Google Analytics back to Marketo

Now that we’ve built all this cool data inside Google Analytics, what do we do with it? After all, while having access to this data is great, it can be a little opaque to work with. While Google Analytics is very useful for looking at data in aggregate, it’s less useful for looking at data individually—this really is the job of platforms like Marketo and your CRM. As a result, we’re going to need to extract the data and send it back to your Marketo instance to take action.

The Analytics Core Reporting API is built to distribute the data you’ve collected inside Google Analytics and send it elsewhere to other web services, such as…Marketo! Google offers some quick examples using JavaScript, Java, Python and PHP on how to create an API connector, but a handful of other wrappers are available if you’re looking for help in another programming language. Once you’ve set up your API connector, I recommend using Google’s Query Explorer to get an idea of some of the basic functions you can perform with the API. Those looking to do more complex operations should do a deep dive into the Dimensions and Metrics Explorer to see what combinations of values can be extracted from the API.

As an example, I’ve built a very basic query to retrieve users with Marketo IDs and calculate their average time on the website for the past 30 days using: https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3AYYYYYYYYY&start-date=30daysAgo&end-date=yesterday&metrics=ga%3AavgTimeOnPage&dimensions=ga%3Adimension1.

This returns the following JSON results, which show both the Marketo ID of a user and their average time spent on a page—as you can see, good ol’ 7498 (a.k.a. this author) has no time to be spending on individual pages. From here, you can integrate the query into your larger Marketo API connections to send this data, using the Marketo ID as a key, to custom fields, storing whatever data you want.

Content Groups, Custom Dimensions and Events give you a bird’s-eye view into your content performance and website traffic within Google Analytics. The invaluable insight you get as a result of implementing these within your system—what content items are performing best, why your forms aren’t converting visitors, how many visitors shared your content—allows you to deeply analyze what works and what doesn’t, helping you to improve the quality of what you’re putting out there and how you are putting it out there.