concept2.jpg

Google Analytics and Marketo: Events and Forms and APIs, Oh My!

Level 8
concept2.jpgBasic 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. Seeing as 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&ui...{{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.

marketo webhook analytics interesting moments

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

marketo google analytics integration event

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.

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.

2016-05-24_1429

In this example, clearly people are stopping after First Name. This empowers you to examine your form setup and figure out why.

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=yes...

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.

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.

6058
22
22 Comments
Level 8 - Champion Alumni

This is awesome work Courtney Grimes! Thanks for sharing. 

The capability to bring individual data back from GA into Marketo interests me a lot. Several years ago I explored this but ran into some obstacles including concerns around storing PII in GA and also data sampling in the standard edition of GA. (We ended up using KissMetrics instead.)

Two questions from me:

1) I'm wondering if you could expand a bit on the approach here for how you need to set up GA to get the data back. You are pulling data that includes the Marketo ID. Are you configuring anything else to pass the Marketo ID in the first place or is that done as part of the IM webhook?

2) GA does a great job of tracking source for every web session. I've often wondered why we can't just grab that data into Marketo instead of building source tracking directly in Marketo. Do you think your approach could be modified to pull this data -- e.g., every time a new session is initiated, grab the source details and pass them into Marketo fields?

Thanks again!

Hey Justin,

Indeed, the issue of PII is why I got into the habit of using Marketo IDs as the UID of record for Marketo customers (though I've toyed with using the Marketo cookie ID with Munchkin 2.0's changes)—all I'm doing is echoing the lead ID into UID and a dimension either via token (for Marketo LPs) or getLead/leads.json on the first visit per session if outside of Marketo on a website/in-app.

In terms of your second question, I'm actually against doing direct data pushes into Marketo fields for tracking data just because it's a reductionist view of how source tracking goes—I mean, it can kind of work if you're just going all in with one or two mediums (i.e., just emails and your corporate website) but things are much messier in the real world where your leads are going to do 20 different things before bothering to engage you directly. That's why I just echo faux URLs with tracking data and then re-analyze it elsewhere; if I push the data into a field I want to make sure I've accounted for every touch, not just the three someone bothered to tag.

I totally get that I'm currently in the minority as far as THAT goes, though, so you could always just dump your UTM parameters into a cookie and have it process at a form fillout—just heaven forbid they click on two links or something. :X

Wow this is indeed a great blog post Courtney Grimes​ and certainly tackles some of the current challenges we have so I'll be sure to add some of these ideas into our Marketo instance. Thank you so much for taking the time to write this with all the details and tutorial steps.

Level 7 - Champion Alumni

This was amazing, Courtney Grimes​! Thanks for sharing!

Anonymous
Not applicable

This is a great post. Has anyone compared this Marketo/GA configuration approach to using a tool like Segment to build a hub and spoke model for publish-once event generation from mobile/tablet/desktop apps/sites to many platforms (i.e. Marketo, GA, and CMS)?

What have been the outcomes of using the approach recommended approach.  A short conversation with someone willing to share 'lessons learned' would be greatly appreciated!

Thanks!

Anonymous
Not applicable

What an awesome and super helpful post here Courtney Grimes . I've implemented the first step here with the webhook...and it worked. Yahoo! (Well, for Yahoo and all other sources )

A new issue popped up though with 98% of Event Actions = undefined. Any idea about where this could possible be coming from? Other conversions are working (lead generation) yet there are all of these additional events being tracked. They are all in the correct category, I just used Interesting Moment as the category.

Anonymous
Not applicable

HAHA! It just hit me, like a ton of bricks. I'll just update the GA goal to filter out "undefined"...rather just select some characters that all of our forms have in common and BOOM it's done. Yahoo!

So, if undefined is coming through with anyone else, this doesn't resolve the issue with them coming in yet just tracks them in a different way so as they aren't tied to goals.

Anonymous
Not applicable

Hi and thank you Courtney Grimes​​ for this post! So totally awesome. (You can see from my last post that I've already worked out this issue with formatting this information.)

I've created a goal for anyone who completes these events so as I can see which source/medium is sending the best quality traffic. However according to GA, the only source sending traffic which converts is Direct. Comparing this against the Marketo lead database Source Information I can see this is not accurate. Any insights into why this might be?

Anonymous
Not applicable

Thanks so much! This has been something on my list to implement for a long time so we can measure Marketo activities in GA!

I'm not super well-versed in API and webhooks so I was hoping someone could help me out with one piece of the puzzle that's missing for me?

I want to know what URL / page our traffic is completing these forms on, but the webhook doesn't seem to record that in the event. anyone know how I can accomplish that? (We utilize a global form approach)

{{trigger.Web Page}} doesn't seem to be an option for the webhook.

Great article Courtney Grimes​ - I'm looking into implementing this but just concerned about API limit. We have a 10000 Daily API limit, so if I set up this webhook does this mean every time it logs an interesting moment for a lead that we send to Google Anaytics it would count as 1 API request out of 10000? Also, do you have any recommendations on what kinds of interesting moments would be best to track, especially with the API limit in mind?