Lead Tracking

Marketo’s Munchkin JavaScript allows for tracking of end-user page visits and clicks to your Marketo landing pages and external web pages.  These are recorded in Marketo as “Visit Web Page” and “Clicked Link on Web Page” activities, which can subsequently be used in triggers and filters for Smart Campaigns and Smart Lists.

Embedding the Code

Your Marketo instance automatically provides preconfigured tracking code snippets to embed code on your external pages which will track activity back to your Marketo instance.

There are 3 tracking code types available:

  1. Simple – Executes synchronously
  2. Asynchronous – Executes asyncronously
  3. Asynchronous jQuery – Executes asynchronously and requires that jQuery be loaded beforehand

It is highly recommended that the Asynchronous tracking code be used for embedding Munchkin on external pages.  To ensure the highest possible success rate for execution, embed the Asynchronous tracking code in <head> of each page.

Note that some content management systems may have specific methods or restrictions when embedding arbitrary scripts.

For reference, your final page should include code similar to this in <head> of your HTML document:

Munchkin Behavior

The default behavior of Marketo Munchkin is to do the following on page load:

  1. Check to see if the current browser has a Munchkin cookie and create one if it is not there.
  2. Send a “Visit Web Page” event to the designated Marketo instance using the information from the current page and browser.  This records an activity to the corresponding record in Marketo.
  3. Send “Clicked Link on Web Page” event for any user clicks that occur on links.

The behavior of Munchkin can be modified through the usage of Munchkin Configuration settings, such as whether a cookie is created for all leads upon visiting the page with the cookieAnon setting, or modifying the click delay with clickTime setting.

Known and Anonymous Leads

On a lead’s first visit to a page on your domain, a new anonymous lead record will be created in Marketo.  The primary key for this record is the Munchkin cookie (_mkto_trk) which is created in the user’s browser.  All subsequent web activity on that browser will be recorded against this anonymous record.  In order to be associated to a known record in Marketo, one of the following things must occur:

  • The lead must visit a Munchkin-tracked page with an mkt_tok parameter in the querysytring from a tracked Marketo email link.
  • The lead must fill out a Marketo Form.
  • A Munchkin associateLead call must be sent to your Marketo instance.
  • A SOAP syncLead or REST Associate Lead call must be sent.

Once one of these conditions is fulfilled, the cookie and all associated web activity will be associated to the known lead.

NOTE: A new anonymous web activity record is created for each individual browser, so if a lead visits your domain for the first time using a new computer and/or browser, then this association must take place again.


Munchkin creates and tracks individual cookies on a per-domain basis, so for known-lead tracking to occur across domains, a lead association event must occur for each domain.  For example, if I control two domains, marketo.com, and example.com, and a lead fills out a form on marketo.com, then navigates to example.com later, then their activity on marketo.com will be tracked on a known lead record, but their activity on example.com will be anonymous.  Known leads will persist across subdomains however, so a known lead on www.example.com is also a known lead on info.example.com.

In the case that your top-level domain is two parts, such as .co.uk, then you will need to add a domainLevel parameter to your Munchkin snippet in order for the code to track correctly.  See here for more details.


The Munchkin cookie uses the key _mkto_trk, and has a value following this pattern:


Munchkin cookies are specific to each second-level domain, i.e. example.com.  The default lifespan of the cookie is 730 days.