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

Casey_Grimes
Level 10
Level 10
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.

14870
22
22 Comments