At the end of our Marketo landing pages, we have a parameterized Munchkin init function:
<script type="text/javascript" src="//munchkin.marketo.net//munchkin.js"></script><script>Munchkin.init('123-xxx-456', {parameter1: 'foo', parameter2: 'bar'});
</script>
We use Google Tag Manager across our sites (including our Marketo landing pages), and we would like to include the Munchkin code snippet in it, ie:
<script type="text/javascript">
(function() {
var didInit = false;
function initMunchkin() {
if(didInit === false) {
didInit = true;
Munchkin.init('123-xxx-456');
}
}
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//munchkin.marketo.net/munchkin.js';
s.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
initMunchkin();
}
};
s.onload = initMunchkin;
document.getElementsByTagName('head')[0].appendChild(s);
})();
</script>
Would that override/break the parameterized Munchkin code that is already being included on our pages?
Thanks in advance!
Mary
HI Sanford,
This makes sense, but how do I refire the munchkin once the visitor has accepted cookies?
-Greg
Munchkin.init().
This still means you're adding a level of indirection, but you can at least still load the Munchkin bootstrapper initially.
With Munchkin Enhanced you can delay the cookie creation while still preloading the small bootstrapper and the real library.
Hi Mary,
You should not have the munchkin fired twice. You may want to make sure that the version in GTM is the parameterized one and remove the one from the pages.
-Greg
Thank you, Greg. How would I remove munchkin from marketo landing pages? I have checked the form, template and landing page itself, and it doesn't seem to be hard-coded. Maybe there's a setting I'm overlooking.