Solved
How to delete the Marketo tracking cookie right after it was set?
To meet German privacy laws (don’t ask for the details – we have such strange laws in Germany) I have do delete the Marketo tracking cookie right after it was set – on the same page. What I’m looking for is a JavaScript event to use as a trigger.
Here is the setup:
Just inserting the “delete cookie” JS code after the Munchkin.init and Munchkin.munchkinFunction calls does not work. Obviously the cookie is set shortly after the delete command is executed.
Possible solution:
I think an event listener would do the trick. So my question is: Is there any easy way to hook on the cookie handling of the Munchkin script? Or do I have to build a listener which checks for cookie changes every second or so (as described here)? To be honest, I have not yet worked much with event listeners in JS.
Here is the setup:
- On a thank you page, which is shown after a non-Marketo form is submitted, I check via JavaScript if the _mkto_trk exists and store this information in a variable (“formerlyKnownLead”).
- Then the Munchkin code (with “cookieAnon: false”) is executed, expanded by the associateLead part.
- Because of the associateLead part the tracking cookie is set.
- After the tracking cookie is set I have to check if the formerlyKnownLead variable is true or false. If it is false, I have to delete the tracking cookie instantly.
Just inserting the “delete cookie” JS code after the Munchkin.init and Munchkin.munchkinFunction calls does not work. Obviously the cookie is set shortly after the delete command is executed.
Possible solution:
I think an event listener would do the trick. So my question is: Is there any easy way to hook on the cookie handling of the Munchkin script? Or do I have to build a listener which checks for cookie changes every second or so (as described here)? To be honest, I have not yet worked much with event listeners in JS.