8

Recently I noticed some performance issues in my site's javascript code. After some profiling I discovered that the problem is the Marketo Munchking code I use to track events. It looks like lately they changed their JS code to send synchronous http request for every call to Munchkin.munchkinFunction. The relevant code snippet is:

a=new XMLHttpRequest;a.open("GET",b,!1); ... a.send();

I've opened a ticket with Marketo, but until they fix their code, I'm looking for a workaround. I thought of a few:

  1. Is there a way to hook their js code to force the XMLHttpRequest to be async?
  2. It is safe to reference directly to older versions of their script, for example //munchkin.marketo.net/143/munchkin.js. I tested it and it works but maybe I'm missing something.

Are there any more workarounds? Any thought is appreciated.

UPDATE:

Just got a response from Marketo support. They admit that the calls are indeed synchronous, but they claim that this is the only way not to lose information. I guess they think of the case when a call to Munchkin.munchkinFunction is made just before a redirect. I disagree with them, and will ask them to provide an alternative. In the mean time I'm using an old version of their code.

UPDATE #2:

Got another response from their support team that said my ideas are good, but they can't implement them right now, and they hope that one of the developers will pick them up someday... Anyway I've created an idea in the Marketo community.

12

Update (Oct 2015): this feature is now documented here.

I just went over the new version of the Munchkin code (150) and found the following undocumented parameter:

Munchkin.init('XXXXXX', {asyncOnly: true});

I tried it and it does the job - all the HTTP requests are now async.

1
  • I stumbled on this as well, but I can't seem to find what the pros/cons are for having it as false vs true. Obviously your requests are now truly async, but why is the default false here? – kamelkev Aug 24 '17 at 0:20
0

Are you definitely using the asynchronous version of the tracking code? If you look in your Marketo admin, under Tracking Code, there is a drop-down to select the Tracking Code Type - make sure this is on Asynchronous, and then use that particular script block in your site.

Also, if you look under the Treasure Chest section in the admin, there is an option to enable the beta Munchkin code - maybe enabling try that if the above doesn't work.

3
  • Definitely the async code. I'll try the beta code, but I've just got a response from Marketo support. See my updated question. – Tzach Sep 14 '14 at 12:03
  • hmm, that is a bit of a gotcha, will have to watch out for that one. good luck! – michaelroper Sep 14 '14 at 14:20
  • You can't select the asynchronous tracking code option from the Marketo admin tool. It's says it's asynchronous but it's really not. It will still attempt to treat link clicks as synchronous calls which also won't respect the default 350 millisecond "clickTime" timeout specified in their docs. You have to explicitly specify "asyncOnly: true". Their JavaScript snippet was making our web properties take 6+ seconds whenever a user clicked on a link as well as triggering popup blockers whenever we tried to open a link in a new tab. – user1212241 Feb 17 '17 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.