Single Page Application Web Tracking with Munchkin & RTP

Anonymous
Not applicable

Continuing Murta Manzur's blog post: Single Page Application Web Tracking with Munchkin, here is how you can also use the RTP tracking code on single page applications.

A Single Page Application is a website that loads all of the resources required to navigate the site on the first page load. When a user clicks a link the content is loaded from the first page load data. To the user, the website behaves as expected because the URL in the address bar is like the traditional page navigation.

Munchkin works well with traditional websites because Munchkin runs every single time the users load a new page. However, with a single page application if you are not loading a new page, Munchkin will run only once.

The approach I’ll walk through in this post is to track when a user clicks on a link, and then send this information to Munchkin. We’ll implement this using the clickLink Munchkin function. Below is an example implementation in jQuery that binds for click events to the clickLink Munchkin method. When calling the clickLink Munchkin method it passes the parameter for the URL that was clicked.

Implement the following JS code after the Munchkin and RTP tags.

<script>

$('body').on('click',function(e){

     var urlThatWasClicked = e.target.href;

     if(typeof(urlThatWasClicked) != 'undefined'){

          Munchkin.munchkinFunction('clickLink', { href: urlThatWasClicked});

          rtp('send','view', urlThatWasClicked);

          rtp('get', 'campaign',true);

     }

});

</script>

3064
3
3 Comments