Add Munchkin Tracking Code to Your V3 Hub

Modified on Tue, 02 Apr 2024 at 03:06 AM

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 Hubs > Custom Code 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>

 
To add the above Munchkin code to your Hub, Go to Hubs > Select the Hub >>Custom Cde >Add code in the Code Section and Save.

 

On the Custom Code listing page, the Munchkin code created is displayed and you can Enable or Disable the code using the Toggle.



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
    });
});


To add the above Munchkin Tracking code to your Hub, Go to Hubs > Select the Hub >>Custom Code >Add code in the Code Section and Save.

 

On the Custom Code listing page, the Munchkin Tracking code created is displayed and you can Enable or Disable the code using the Toggle. 


Click Change Order to reorder the created codes.  


Drag and Drop to change the order and click Save. 


The changed order is displayed in the Custom Code listing page.


Note: Based on the Order configured, the script will trigger accordingly in 1,2 and 3 sequence.



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 atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article