AnsweredAssumed Answered

Modify Munchkin code on landing pages?

Question asked by 6fbb190527133b8f6de483ec33926fbdb27af889 on Oct 29, 2014
Latest reply on Oct 29, 2014 by 6fbb190527133b8f6de483ec33926fbdb27af889
I’m just setting up our own (responsive webdesign) template for landing pages. As far as I could see analyzing the standard templates, the Munchkin tracking code is rendered on a landing page as part of the $mContext['endElements'] output which is included via PHP.

Now my question is: Is there a way to modify or enhance the Munchkin code which is included via the $mContext['endElements'] output?

Or if this is not possible: Is there a way to get hold of the two parameters (“
customName” and “wsInfo”) which are in cluded in the Munchkin code call via the $mContext['endElements'] output? So I could use them in a custom Munchkin code call? Or are there more parameters which I couldn’t see in my test yet?

Here’s the reason why I want to do this:

As a German company we have to be compliant with German privacy laws. This means: Every web tracking system (which the Marketo Munchkin code is) we use on our site has to offer an Opt-out option, so anonymous visitors can choose to turn off being tracked.

Marketo doesn’t offer such a system by default. So I built one. In our new privacy policy (which isn’t online yet) I will include a “Marketo tracking opt-out” link. When an anonymous web lead clicks this link the Marketo tracking cookie “
_mkto_trk” for our domain is deleted and a new cookie “marketoTrackingOptOut” is set.

To prevent a new “_mkto_trk” to be set for an anonymous web lead which has opted out and has the “marketoTrackingOptOut” cookie stored in the browser, I have to modify the Munchkin call: The “cookieAnon: false” option has to be included if – and only if – the “marketoTrackingOptOut” cookie is present.

One way of doing this is a simple piece of JavaScript which replaces the original Munchkin code:
<script src='//'></script>
<script type="text/javascript">
  function getCookie(c){var b=document.cookie;var e=c+"=";var d=b.indexOf("; "+e);if(d==-1){d=b.indexOf(e);if(d!=0){return null}}else{d+=2;var a=document.cookie.indexOf(";",d);if(a==-1){a=b.length}}return unescape(b.substring(d+e.length,a))};
  var myCookie = getCookie('marketoTrackingOptOut');
  if (myCookie == null) {
  } else {
    Munchkin.init('###-###-###', { cookieAnon: false });

This works perfectly on our website. But to prevent new tracking cookies to be seton landing pages when visited by anonymous web leads who opted out, this if-then rule based on the existence of the “marketoTrackingOptOut” has to be incorporated in landing page templates, too. If I just use the above piece of JavaScript instead of the <?php echo $mContext['endElements']; ?> call I don’t get the “Program Type” and “Program Name” information as details of a known leads visit of this particular landing page.

I don’t know yet if I really need these two pieces of information in my reports. But it would be cool if there is an easy way to use my cookie-based enhanced Munchkin call on landing pages without having to omit the above mentioned additional information.