Configuring Different Marketo Munchkin Code to specific site environments under Analytics extension | Community
Skip to main content
New Participant
March 14, 2024
Solved

Configuring Different Marketo Munchkin Code to specific site environments under Analytics extension

  • March 14, 2024
  • 1 reply
  • 978 views

Team,

 

Anyone had a chance to load unique Marketo munchkin code specific to environments under the Adobe Analytics extension code editor.

 

I need to load the unique munchkin code to the different environment. Like Sandbox Marketo Munchkin code to load only in DEV/QA/UAT site.and Production Marketo Munchkin code only in Live site.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by AbhilashSh

Hi @roystonpr  ,

I dont think there is a way to do this in extension itself. You have to rely on custom code.

You can use custom code Adobe Launch rule action to set munchkin ID basis hostname/ URL as per your needs.

Below is sample code how you can achieve. Set Rule Event as "Core - DOM Ready" or "Core - Window Loaded" or "Core - Library Loaded" based on your need.(Any one event)

Set the action as a custom code with below code (Sample code needs to be fine tuned as per your needs. You will have to add hostname values along with Marketo ID and wsInfo value). I hope this helps!

 

 

//Define logic to set munchkin ID basis URL/ hostname var munchkinId = "Your Default Production munchkin ID" if(window.location.hostname === "Your Dev Website HostName"){ munchkinId = "Dev Munchkin ID goes here"; } else if(window.location.hostname === "Your Stage Website HostName"){ munchkinId = "Stage Munchkin ID goes here"; } //Munchkin script (function() { var didInit = false; function initMunchkin() { if(didInit === false) { didInit = true; Munchkin.init(munchkinId, {"wsInfo":"abcd"}); } } 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); })();

 

 

1 reply

AbhilashShAccepted solution
New Participant
April 3, 2024

Hi @roystonpr  ,

I dont think there is a way to do this in extension itself. You have to rely on custom code.

You can use custom code Adobe Launch rule action to set munchkin ID basis hostname/ URL as per your needs.

Below is sample code how you can achieve. Set Rule Event as "Core - DOM Ready" or "Core - Window Loaded" or "Core - Library Loaded" based on your need.(Any one event)

Set the action as a custom code with below code (Sample code needs to be fine tuned as per your needs. You will have to add hostname values along with Marketo ID and wsInfo value). I hope this helps!

 

 

//Define logic to set munchkin ID basis URL/ hostname var munchkinId = "Your Default Production munchkin ID" if(window.location.hostname === "Your Dev Website HostName"){ munchkinId = "Dev Munchkin ID goes here"; } else if(window.location.hostname === "Your Stage Website HostName"){ munchkinId = "Stage Munchkin ID goes here"; } //Munchkin script (function() { var didInit = false; function initMunchkin() { if(didInit === false) { didInit = true; Munchkin.init(munchkinId, {"wsInfo":"abcd"}); } } 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); })();