Add Munchkin Tracking Code to Your Hub

Modified on Mon, 26 Jun, 2023 at 9:37 PM

Marketo’s custom JavaScript tracking code, called Munchkin, tracks all visitors who visit your Hub so you can react to their visits with automated marketing campaigns. Anonymous visitors are also tracked along with their IP addresses and other information. Without this tracking code, you will not be able to track visits or other activity on your hub.


Adding Marketo Tracking Code to Your Hub:

Use the Asynchronous Munchkin code and place it inside the Head section of your Hub or in your Google Tag Manager.

<script type="text/javascript">
  (function() {
    var didInit = false;
    function initMunchkin() {
      if(didInit === false) {
        didInit = true;
        Munchkin.init('CHANGE-ME');
      }
    }
    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>

Go to Hub > Branding > Head section and paste the above content.




Tracking the Hushly Events in Marketo

Marketo does not support tracking of custom events. As a workaround, we propose to use munchkinFunction to  trigger a link click event.


Hushly's Solution:

There is a method that you can use to track Actions in Marketo through a 'Clicked Link' activity. If you are looking to track events on the Asset in your pages, the most simple way is to show a 'Clicked Link on Webpage' activity:


This is possible by using a Munchkin tracking code in the Action and some extra code. To track Hushly's events like Content View, Content Interaction, Form Submits, etc copy the below code,

hushly('bind', 'content-view', function(options) {
    Munchkin.munchkinFunction('clickLink', {
        'href': '/hushly/activity?utm_source=Hushly&utm_action=content-view&utm_content=' + options.assetName
    });
});

hushly('bind', 'content-interaction', function(options) {
    Munchkin.munchkinFunction('clickLink', {
        'href': '/hushly/activity?utm_source=Hushly&utm_action=content-interaction&utm_content=' + options.assetName
    });
});

hushly('bind', 'invalid-form-submit', function(formData) {
    Munchkin.munchkinFunction('clickLink', {
        'href': '/hushly/activity?utm_source=Hushly&utm_action=invalid-form-submit&utm_content=' + formData.assetName
    });
});

hushly('bind', 'form-submit', function(formData) {
    Munchkin.munchkinFunction('clickLink', {
        'href': '/hushly/activity?utm_source=Hushly&utm_action=form-submit&utm_content=' + formData.assetName
    });
});


Go to Setup > Settings > Event Handlers section and paste the above code.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article