SOLVED

Re: Create a LP that clears you Cookie!

Go to solution
Diederik_Marte4
Level 6

Create a LP that clears you Cookie!

Even though we inform our colleagues, somehow some still fill out a form on someone's behalf or click a link in a forwarded email. I'm thinking about creating a blank landing page that clears the current Marketo cookie on visit (obviously with noindex, nofollow, etc). And then have that secret landing page set as homepage for sales reps and marketers. This way we prevent rogue behavior (page vists, etc) on a lead, whilst it actually was a sales rep accidentely tagged as the lead.

I'm thinking about a few ways of achieving this, but maybe someone already cracked this 😉 Maybe just a simple line of code that sets the date of the Marketo cookie in the past. But then I do need to know how to reference it. Any ideas?

6x Marketo Champion | Marketo Certified Solutions Architect (MCSA) | Marketo User Group Leader | International Speaker on Marketing Technology
1 ACCEPTED SOLUTION

Accepted Solutions
Grégoire_Miche2
Level 10

Re: Create a LP that clears you Cookie!

Hi Diederik Martens ,

Indeed

  1. Create a LP TEMPLATE that does not have the munchkin (this is done in editing the template and hitting the following menu:pastedImage_3.png
  2. Add to you template a couple of JS that will clear cookies and prevent them from being posted to Marketo on form submit:

<!-- CREATE EMPTY MUNCHKIN COOKIE - TO ESENTIALLY MAKE THE PAGE UNTRACKABLE -->

  <script>document.cookie = "_mkto_trk=;path=/;domain="+".inficiences.com"+";expires=0"</script>

<!-- END -->

 

<!-- Clear the Marketo tracking cookie value on submission of the form, without having to delete the cookie itself from the user’s browser. -->

  <script>

  //add a callback to the first ready form on the page

    $(function() {

      MktoForms2.whenReady( function(form){

      //add the tracking field to be submitted

        form.addHiddenFields({"_mkt_trk":""});

        //clear the value during the onSubmit event to prevent tracking association

        form.onSubmit( function(form){

        form.vals({"_mkt_trk":""});

      })

    })

  })

  </script>

-Greg

View solution in original post

12 REPLIES 12
Grégoire_Miche2
Level 10

Re: Create a LP that clears you Cookie!

Hi Diederik Martens ,

Indeed

  1. Create a LP TEMPLATE that does not have the munchkin (this is done in editing the template and hitting the following menu:pastedImage_3.png
  2. Add to you template a couple of JS that will clear cookies and prevent them from being posted to Marketo on form submit:

<!-- CREATE EMPTY MUNCHKIN COOKIE - TO ESENTIALLY MAKE THE PAGE UNTRACKABLE -->

  <script>document.cookie = "_mkto_trk=;path=/;domain="+".inficiences.com"+";expires=0"</script>

<!-- END -->

 

<!-- Clear the Marketo tracking cookie value on submission of the form, without having to delete the cookie itself from the user’s browser. -->

  <script>

  //add a callback to the first ready form on the page

    $(function() {

      MktoForms2.whenReady( function(form){

      //add the tracking field to be submitted

        form.addHiddenFields({"_mkt_trk":""});

        //clear the value during the onSubmit event to prevent tracking association

        form.onSubmit( function(form){

        form.vals({"_mkt_trk":""});

      })

    })

  })

  </script>

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Create a LP that clears you Cookie!

Hey Greg --

To delete a cookie, use

'expires=' + new Date(0).toGMTString()

not

'expires=0'

The latter sets a session cookie with no value, which isn't the same as deleting the cookie (for example '_mkto_trk' in <cookie object> would still be true). For Munchkin in particular it will still work but isn't the right general approach.

new Date(0) sets an expired cookie, which means actual deletion.

Also, you don't need the form stuff if you're deleting the cookie before the form loads.

Grégoire_Miche2
Level 10

Re: Create a LP that clears you Cookie!

Thx !

In fact I had this in some of our templates, which it self came from that post, if I remember well: Non-trackable landing page is still identifying me 

-Greg

Diederik_Marte4
Level 6

Re: Create a LP that clears you Cookie!

Thank you Grégoire and Sanford

I'm not about the form part, as there won't be any. Wouldn't the first line be enough, on a none-tracking-page, to clear the cookie for the specific domain (e.g. main website):

<script>document.cookie = "_mkto_trk=;path=/;domain="+".examplesite.com"+";expires=Thu, 01 Jan 1970 00:00:00 UTC"</script>

And add such a line for each (sub)domain that you're tracking. Then just visiting that page with the script would clear all Marketo cookies a sales rep might have?

6x Marketo Champion | Marketo Certified Solutions Architect (MCSA) | Marketo User Group Leader | International Speaker on Marketing Technology
SanfordWhiteman
Level 10 - Community Moderator

Re: Create a LP that clears you Cookie!

<script>document.cookie = "_mkto_trk=;path=/;domain="+".examplesite.com"+";expires=Thu, 01 Jan 1970 00:00:00 UTC"</script>

And add such a line for each (sub)domain that you're tracking.

Yes, though I wouldn't duplicate the code but iterate a collection:

['.example.com','.example.net','.example.org'].forEach(function(domain){

  document.cookie = '_mkto_trk=;path=/;domain=' + domain + ';expires=Thu, 01 Jan 1970 00:00:00 UTC';

});

Diederik_Marte4
Level 6

Re: Create a LP that clears you Cookie!

Hi Sanford,

Just checking that if I have a collection of domains and subdomains (e.g. sub.domain.com, www.domain.com, www.otherdomain.com, and newdomain.com), how the code would be. Because I think cookies can be shared with subdomain, but it has to be explicitely stated. And I don't think the Marketo cookies have that right. Could I mix domains and subdomains in the array infront of "forEach( ?

6x Marketo Champion | Marketo Certified Solutions Architect (MCSA) | Marketo User Group Leader | International Speaker on Marketing Technology
Diederik_Marte4
Level 6

Re: Create a LP that clears you Cookie!

P.s. It's been a while.... 😉 And never used Javascript for cookies 😉

6x Marketo Champion | Marketo Certified Solutions Architect (MCSA) | Marketo User Group Leader | International Speaker on Marketing Technology
SanfordWhiteman
Level 10 - Community Moderator

Re: Create a LP that clears you Cookie!

Marketo cookies have that right.

All cookies have that right, actually, and Marketo cookies are always shared with subdomains.  You should tell Munchkin to set cookies at the uppermost private domain possible so that all subdomains of that domain are covered.  (This often needs manual intervention, since it doesn't work automatically at all TLDs: see here.) If you're always setting your cookie at ".example.com" then that's the only domain you need to clear from.

You can mix any subdomains and domains in the array in the code above.  Domains that don't match at all (like ".example.com" when the current URL is "www.example.net") will simply be ignored. You can't alter cookies from other domains but there's no error thrown if you try.

This post is also relevant.

Diederik_Marte4
Level 6

Re: Create a LP that clears you Cookie!

I guess I'm not fully awake yet. Obviously I can't clear a cookie from another domain. This also means I can only use a Marketo LP to clear my main website cookie or Marketo LP cookie of it's on the same domain, which ussually is the case. Perhaps I can have each extra domain host their own page to clear.  And then have a single page with iframes to load each page, so you can still clear all cookies all at once.

I have enough to get going. Thank you so much Sanford.

6x Marketo Champion | Marketo Certified Solutions Architect (MCSA) | Marketo User Group Leader | International Speaker on Marketing Technology