Hi Experts,
I have injected munchkins js in my webpage using following code:
<script type="text/javascript">
(function() {
var didInit = false;
function initMunchkin() {
if(didInit === false) {
didInit = true;
Munchkin.init('token-AAA');
}
}
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);
document.onclick = function(event) {
event = event || window.event; // IE specials
var target = event.target;
if(target.nodeName === "A") {
var urlThatWasClicked = 'https://console.someurl.com/dashboard';
Munchkin.munchkinFunction("visitWebPage", {
url : urlThatWasClicked
});
}
};
})();
</script>
On Click of the link, I want to send email using campaign.
I created a campaign and following is the smart list configuration:
and following is the flow configuration:
In the scheduled tab I have activated the campaign.
Now as soon I link on the link in my webpage, email should be sent to the email ID specified in "To Other Emails" but it's not working. Am I missing anything here?
Really appreciate your inputs on this.
Solved! Go to Solution.
Thanks for making that change.
There are several problems with your code.
You need to identify your special links so only those links become custom visitWebPage calls.
Do this by decorating the interesting links with an HTML data- attribute.
Then look for that attribute and only send the custom call if it exists. Note: if you have a link that would ordinarily be logged (as a clickLink) by Munchkin, and you want to control it with your custom code instead, add class="mchNoDecorate" to the link.
<a data-munchkin-log-as-visit href="#internal-navigation">Some app menu item</a>
<script>
document.addEventListener("click", function(event) {
if( event.target.hasAttribute("data-munchkin-log-as-visit") ) {
var urlThatWasClicked = 'https://console.someurl.com/dashboard';
Munchkin.munchkinFunction("visitWebPage", {
url : urlThatWasClicked
});
}
});
</script>
Please don't post screenshots of code, post actual text highlighted using the syntax highlighter.
After you delete the image and replace it with text, we'll continue.
I updated image with code snipped. Kindly share your inputs.
Thanks for making that change.
There are several problems with your code.
You need to identify your special links so only those links become custom visitWebPage calls.
Do this by decorating the interesting links with an HTML data- attribute.
Then look for that attribute and only send the custom call if it exists. Note: if you have a link that would ordinarily be logged (as a clickLink) by Munchkin, and you want to control it with your custom code instead, add class="mchNoDecorate" to the link.
<a data-munchkin-log-as-visit href="#internal-navigation">Some app menu item</a>
<script>
document.addEventListener("click", function(event) {
if( event.target.hasAttribute("data-munchkin-log-as-visit") ) {
var urlThatWasClicked = 'https://console.someurl.com/dashboard';
Munchkin.munchkinFunction("visitWebPage", {
url : urlThatWasClicked
});
}
});
</script>
Thanks. This is really helpful.
I missed a part of documentation where it says -
In order to be associated to a known record in Marketo, one of the following things must occur:
Once I added marketo form and submitted it, my emails were getting triggered.