AnsweredAssumed Answered

Custom de-duplication: Create new cookie on form submit

Question asked by Markus Bianchi on May 27, 2018
Latest reply on May 28, 2018 by Sanford Whiteman

A customer is using a custom de-duplication logic (email address and an additional field). When a person is submitting a form, Marketo is only using this custom de-duplication check if the person is unknown. For known people, the cookie will "trump" the field values, when it comes to the dedupe logic. In most cases that's desirable and therefore the expected result.

 

However, in this specific case, we always want to use the custom de-duplication logic rather than the cookie. So, I tried to delete the existing cookie when a person submits the form and create a new cookie before the form is submitted (in the hope that Marketo would "connect" that newly created cookie with the person that was updated in the database (for tracking/pre-fill reasons)):

 

function deleteCookie(key, path, domain) {
  document.cookie =
    encodeURIComponent(key) +
    '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' +
    (domain ? '; domain=' + domain : '') +
    (path ? '; path=' + path : '');
}

MktoForms2.whenReady(function(form) {
  form.onValidate(function(isValid) {
    if (!isValid) {
      return false;
    }

    deleteCookie('_mkto_trk', '/', 'DOMAIN');

    setTimeout(function() {
      Munchkin.createTrackingCookie(true); 
    }, 10);
  });
});

 

The above code is quite simple, still has a couple of flaws but was just a proof of concept. It deletes the cookie but although I'm using createTrackingCookie() it's not creating a new cookie before the form is submitted (even if I prevent submitting the form with e.g. form.submittable(false);). While this code now forces Marketo to always use the custom dedupe logic (rather than the cookie) it prevents the tracking and pre-filling functionality (assumably because I'm unable to create a new cookie before the form is submitted)!?

 

Does anyone know how to create or force create a new tracking cookie before the form us submitted or why createTrackingCookie() is not working in this case? Maybe Sanford Whiteman?

 

Any help is greatly appreciated.

 

— Markus

Outcomes