Skip to content

Instantly share code, notes, and snippets.

@mozz100
Created January 30, 2012 12:03
Show Gist options
  • Save mozz100/1704066 to your computer and use it in GitHub Desktop.
Save mozz100/1704066 to your computer and use it in GitHub Desktop.
Marketo Sales Insight - notify sales team which file was downloaded
/* Use the Munchkin API to record a 'visitWebPage' event (see http://community.marketo.com/MarketoArticle?id=kA050000000Kyr7). Set the url of the visitWebPage event to the url of the download. I found that I had to make the link open in a new window, otherwise the Munchkin never manages to 'call home'...
I did it with jQuery. Replace $jq with a reference to a valid jQuery object in the code below.
We use a separate subdomain for Marketo-hosted landing pages and resources (in common with most users, I suspect). Since we wanted to track downloads for any PDF or PPT file within that domain, the jQuery selector pretty much wrote itself. It's case sensitive, but could easily be extended or modified to work around that - wasn't necessary for me.
Opening the links in a new window seems to help with the tracking. If the new page loads too quickly, then it seemed as if the event handler code didn't get called. Leaving the original window open avoids this (I set target="_blank").
*/
// To include which file was downloaded in an "Interesting Moment" for Sales Insight,
// attach to PDF or PPT links on the Marketo download site.
// Fire a 'visitwebpage' event to Munchkin and make the link open in a new window.
$jq('a[href^="http://info"][href$=".pdf"], a[href^="http://info"][href$=".ppt"]').click(
function(e) {
mktoMunchkinFunction('visitWebPage', { url: $jq(this).attr('href') });
}
).attr('target', '_blank');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment