Munchkin API Reference
Munchkin provides several functions which can be called manually through Javascript. These can allow for customized tracking of browser events, such as video plays, or clicks on non-links.
Functions
The Munchkin API is comprised of the following functions: init
, createTrackingCookie
, munchkinFunction
.
Munchkin.init()
Munchkin.init()
must be called before any other functions. It sets up Munchkin on the current page to send activities to a specific instance and generates a “Visits Web Page” activity for the current page.
Munchkin.init('299-BYM-827');
Munchkin.createTrackingCookie()
When called, this checks to see a _mkto_trk
cookie exists in the browser, and if not, creates one. This is useful for tracking users during specific actions, such as registration or downloading an asset, if cookieAnon
is set to false.
cookieAnon
is set to false.Munchkin.createTrackingCookie(true);
Munchkin.munchkinFunction()
Used for generating custom tracking behaviors, such as video player plays and pauses, or page visits for non-standard navigation, such as hash codes.
visitWebPage
, clickLink
, associateLead
visitWebPage
Calling munchkinFunction()
with visitWebPage
sends a ‘visit’ activity for the current user to Marketo. You can customize the URL and querystring
which are sent with the data object in the second argument.
/index.html
and domain name is www.example.com
, then the visited page is recorded as www.example.com/index.html
.For example, foo=bar&biz=baz
.
Munchkin.munchkinFunction('visitWebPage', {
'url': '/Football/Team/Seahawks',
'params': 'defense=legion_of_boom&qb=wilson'
}
);
clickLink
Calling munchkinFunction()
with clickLink
sends a click activity for the current user to Marketo. You can customize the click URL with the href
property in the data object.
For example, if href is /index.html
and domain name is www.example.com
, then the link click is recorded as www.example.com/index.html
.
Munchkin.munchkinFunction('clickLink', {
'href': '/Football/Team/Seahawks'
}
);
associateLead
This method has been deprecated and is no longer available for use.