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.  Use of the embed code is governed by this license agreement.

There are 3 tracking code types available:

  1. Simple – Loads synchronously
  2. Asynchronous – Loads asyncronously
  3. Asynchronous jQuery – Loads 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.  The sending of the Visit activity may be disabled by setting the apiOnly setting to true.  As of version 162 (August 2022), clicks on tel and mailto links will be tracked in addition to http/s links.

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 query string from a tracked Marketo email link.
  • The lead must fill out a Marketo Form.
  • 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.

Domains

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.

Cookie

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

id:561HYG937&token:_mchmarketo.com137455265641190718

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

Beta

To opt in to the Munchkin beta channel for your landing pages, go to your Admin -> Treasure Chest menu and enable the “Munchkin Beta on Landing Pages” setting.  This will also provide new code snippets in the Admin ->  Munchkin menu to allow you to leverage the beta version on external sites.

Opt-Out

Visitors may opt out of Munchkin tracking entirely by adding the querystring parameter “marketo_opt_out=true” to the URL in their browser.  When the Munchkin JavaScript detects this setting it will attempt to set a new cookie “mkto_opt_out” with a value of true.  All other Marketo tracking cookies will be deleted, no new cookies will be set, and no HTTP requests will be made by Munchkin when this setting is detected.