Add Munchkin Tracking Code to Your V3 Hub

Modified on Sun, 8 Dec at 11:19 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 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, navigate to  Hubs > Select the Hub > from the Hub menu, click Custom Code.  Add the code in the Code Section and Save.

 

The Munchkin code created is displayed on the Custom Code listing page, where you can use the toggle to Enable or Disable the code.



Tracking the Hushly Events in Marketo

Marketo does not support tracking of custom events. As a workaround, we propose to use the Munchkin Function 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 code to your Hub, navigate to  Hubs > Select the Hub > from the Hub menu, click Custom Code.  Add the code in the Code Section and Save.

 

The Munchkin code created is displayed on the Custom Code listing page, where you can use the toggle to Enable or Disable the code.


Click Change Order to reorder the created codes.  


Drag and Drop to change the order and click Save. 


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


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



Related Topics:

Google Analytics 4 Integration

Google Ads Integration Information & Setup

Google Tag Manager (GTM) Information and Setup




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