Re: How to invoke custom activity by using js munchkin function for link click

Akhilesh_Singh
Level 2

How to invoke custom activity by using js munchkin function for link click

I want to post extra details under user's activity when certain type of anchors are clicked, basically want to differentiate between anchors which are open to public and those which are locked(secured ones), so i know how many secured links user is trying to download/click. 

For same i was considering to use this: Munchkin JavaScript API Calls 

But it seems it can only accepted one of 3 predefied/fixed set of values for first parameter. 

like for link click activity, only way to call is this where clickLink is fixed.

mktoMunchkinFunction('clickLink', {
    href: '/MyFlashMovie/Story1'}
);

I tried below format, but didnt work, doesnt make any ajax call to marketo and cant see data in marketo:

here TestCustomActivity is name of cstom activity i created in marketo insatnce, also tried with it's Id, but no success.

Munchkin.munchkinFunction('TestCustomActivity', {
'CustomeProperty1': 'https://developers.marketo.com/rest-api/endpoint-reference/'
}
);

I need below details/solutions, if someone knows, please share.

  1. How do i call/post any of custom activities i have created -via mktoMunchkinFunction i.e. Munchkin.munchkinFunction call?
  2. how to show that custom activity under lead details page's activity tab? what settings to do to get custom activities posted for user's clicks to show under lead details page(posted via @a above)?

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: How to invoke custom activity by using js munchkin function for link click

You cannot log CAs using the Munchkin API. Log "clickLink" or (preferably) "visitWebPage" with a custom namespace.

Ronnie_Duke2
Level 4

Re: How to invoke custom activity by using js munchkin function for link click

One thing that can be useful with the visitWebpage function is the params option. This will allow you to add custom querystrings to the URL which can be used within SmartLists. 

For example, I implemented a 3rd party JS library to detect active time on a page and send back to Marketo:

Munchkin.munchkinFunction('visitWebPage', {
url: document.location.path, params: "pageTime=" + data + "s"
});‍‍‍

This fires in intervals and records in the lead's activity log like this:

pastedImage_5.png

Then, you can use smart lists to trigger off the querystring constraint:

pastedImage_6.png

Not sure if this addresses your specific use case, but perhaps you could use some combo of the data to get what you want.

Cheers,

Ronnie

SanfordWhiteman
Level 10 - Community Moderator

Re: How to invoke custom activity by using js munchkin function for link click

Hope you're stopping the polling after a fixed period. If you run that every s and 1000 people have your tab open, that's 86 million hits per day. Munchkin can't handle that volume!

In any case, yes, by "custom namespace" I meant using the href to record custom data. Using the pathname as a namespace is better for integration than using the qs, since the qs isn't part of the {{trigger.web page}}.

Ronnie_Duke2
Level 4

Re: How to invoke custom activity by using js munchkin function for link click

It only runs every 7 seconds that the tab is currently active and not idle. The plugin I'm using is called Riveted and uses mouse movement, scrolling, keyboard etc to determine if the user is actually active on the page and only advances the timer if so.

I could, however wrap the call in a script to make sure to only send if the time doesn't exceed 2m or something. 

Thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: How to invoke custom activity by using js munchkin function for link click

If it's using the Page Visibility API and other stuff it's likely fine, then.

Just wanted to be clear on that so no one sets up a basic setInterval, as that'll kill your instance.

Of course the right way to store such data -- which Munchkin can't do, because [a] it doesn't have insight into the semantic meaning of what you're sending here and [b] it doesn't support compaction anyway -- is to compact redundant data points. There's no reason to keep the log lines for 7s, 14s, and 21s, as 21s includes 7s and 14s. Advanced timeseries dbs can do this automatically on the back end, and it's critical for scale.