Clearing the Munchkin cookie and the tracking mkt_tok from a form post

SanfordWhiteman
Level 10 - Community Moderator
Level 10 - Community Moderator

There’s a well-traveled Forms 2.0 JS snippet from this Developer Blog post that gets copy-pasted all over:

MktoForms2.whenReady(function (form) {
   form.addHiddenFields({ 
      _mkt_trk: ""
   });
   
   form.onSubmit(function (form) {
      form.vals({ 
         _mkt_trk: ""
      });
   });
})

 

And it works perfectly for its intended purpose. The problem is people may assume it does more than it promises to.

 

What it does

The code above takes advantage of a quirk — not a feature per se— in the Forms 2.0 JS library to ensure that the Munchkin cookie value is not included in the form post. (The cookie is called _mkto_trk, while the corresponding form field is _mkt_trk without the o.)

By omitting the cookie, you don’t associate the current Munchkin web analytics session with the Email Address on the form.

This is critical when creating a Referrer Form setup, or in any other case where you don’t want to change the associated lead, but you also don’t want to delete the cookie completely. (Deleting it means a new anonymous session is created on the next pageview.)

 

What it doesn’t do: Custom dedupe keys

A Marketo Nation user deployed the above code and was surprised that it didn’t solve for their particular case. Their confusion was understandable, as the code sounds like it makes every form post unique, without regard for any previous activity.

In their case, they have a custom dedupe key[1] set up for form submissions. To merge into an existing lead, Marketo matches not just Email Address but the combo of Email Address + Primary Brand.

What they wanted: only the Email Address and Primary Brand values on the form itself are used to find the most appropriate lead. (Primary Brand happens to be a hidden field filled based on the site hosting the form, but could just as easily be a dropdown selected by the user.)

What they got: it worked sometimes, but not if the person reached the page directly from a tracked Marketo link.

And this makes sense, once you take the Marketo association cascade into account. By “cascade” I mean the different data points, with different priorities, that identify the known person behind a web activity.

One of those data points, with let’s call it “high priority”, is a previously associated Munchkin cookie.

Another data point is the mkt_tok query param that’s attached to a tracked link. This value is used to select the known person for the purposes of (native) pre-fill, as long as the cookie agrees. In case of a conflict with the cookie, pre-fill is disabled. But in the complete absence of an associated cookie, whether on the initial pageview or in a form context, the mkt_tok takes over, since it points to the person who received the email (as well as the campaign run and email asset).

So the mkt_tok’s priority varies. But if you want Marketo to only see values explicitly provided by the form-filler-outer, you must kick that field out of the form post.

So a more complete snippet is:

MktoForms2.whenReady(function (form) {
   form.addHiddenFields({ 
      _mkt_trk: "",
      mkt_tok: ""
   });
   
   form.onSubmit(function (form) {
      form.vals({ 
         _mkt_trk: "",
         mkt_tok: ""
      });
   });
})

 

NOTES

[1] n.b. Marketo Support has to do this for you, it’s not in the UI.

1062
0