January 18, 2017

Marketo Event Tracking Using the Munchkin “clickLink” Javascript Function

Many are familiar with Google Analytics event tracking and its associated insights. This is something that HubSpot has implemented (View Image) to a certain degree in their product, but as of right now Marketo is lacking.

If I want to trigger a workflow off of a hover event, or an abandoned form, or some other event that happens on a webpage but doesn’t discretely send Marketo information then I’m shit out of luck.

In a previous post I documented how you could use AddThis share buttons (because the Marketo ones stink), and track their clicks in both Google Analytics and Marketo, and I realized after the fact that this type of functionality might be useful to other Marketo users on a general “event tracking” ┬álevel.

Here is the Google Analytics tracking code:

ga('send', 'event', 'category', 'action', 'label', 'value');

Here is the concept snippet I’ve created for tracking events in Marketo:

function mktoTrackEvent(category, action, label, value) {

_category = category ? category : 'general';
_action = action ? action : 'not set';
_label = label ? label : 'not set';
_value = value ? value : 'not set';

var mktoEventLocation = window.location.href;
var mktoEventString = _category + '/' + _action + '/' + _label + '/' + _value + '/';
var mktoEventUrl = mktoEventLocation + encodeURI(mktoEventString);

Munchkin.munchkinFunction('clickLink', { href: mktolink });

So if you look at the function you are basically tracking events as link clicks in Marketo. If say, you wanted to tracking someone hovering over an element on your page you could use the below snippet to tracking that.

Track a hover event:

$('#element').hover(function() {
    mktoTrackEvent('A Cateogry','Hover','Something','The Value');

Then, create a workflow to trigger off the event:

Once you’ve recorded the event as a link click in Marketo you can then trigger workflows off of it using the clicks link trigger. See the featured image of this post for how that would look.


This is a simple way of tracking specific events. Unfortunately this method does not provide the capability of isolating out the individual values of the event for use in Marketo flows. For example, if you wanted to score people using the values provided by the event, or if you wanted to record interesting moments based on the events. All of this is impossible with this snippet. To achieve that you would have to create several event related fields, a forms with those fields, hide the form on the page, and use the Marketo Forms 2.0 methods to submit it behind the scenes with the values as the use completes events. Or, perhaps created a backend handler to process Ajax calls and send to Marketo via the REST or SOAP API. Perhaps that’s a post for another day.

Leave a Reply

Your email address will not be published. Required fields are marked *