SOLVED

Re: Is there a way to configure the munchkin client-side library to make page tracking requests asynchronously?

Go to solution
Anonymous
Not applicable

Is there a way to configure the munchkin client-side library to make page tracking requests asynchronously?

We've implemented Munchkin in one of our products however every single click on the page translates to a synchronous request to marketo. This means that if Marketo is ever slow to respond, there is a noticeable delay/freeze as the main thread waits for a response from Marketo. Chrome also warns about this:

munchkin.js:10 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Is there a way to configure the munchkin client-side library to make page tracking requests asynchronously?

Yes, this is a documented Munchkin.init() option:

  Munchkin.init( 'AAA-BBB-CCC', { asyncOnly: true } );

You should be aware that this will drastically (almost comically) decrease accuracy. This is by definition, as an async request is not guaranteed to finish before the page is unloaded and all outstanding foreground connections canceled. Even though Munchkin only requires the HTTP request to complete (the cross-domain HTTP response can't even be processed), the cost of starting up the connection will frequently stop the request from completing.

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Is there a way to configure the munchkin client-side library to make page tracking requests asynchronously?

Yes, this is a documented Munchkin.init() option:

  Munchkin.init( 'AAA-BBB-CCC', { asyncOnly: true } );

You should be aware that this will drastically (almost comically) decrease accuracy. This is by definition, as an async request is not guaranteed to finish before the page is unloaded and all outstanding foreground connections canceled. Even though Munchkin only requires the HTTP request to complete (the cross-domain HTTP response can't even be processed), the cost of starting up the connection will frequently stop the request from completing.