Re: Munchkin API Help

Not applicable

Munchkin API Help

Our web pages our built using client-side AJAX and the URL doesn't change, thus the standard analytics-type libraries which send events automatically based on URL changes etc., those are going to miss the majority of what's going on with the user. 

  I assume the Javascript for doing direct, realtime event submission is fairly straightforward, I was wondering someone wouldn't mind posting  a simple example of it how they use it on their website that is also using client-side AJAX

Level 10 - Community Moderator

Re: Munchkin API Help

Given a link like:

<a id="loadAjaxContent" href="#getSome">Get it</a>

Listen for clicks like:


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


Obviously you will want to use classes or some other kind of grouping for simplicity.

Or you could listen for any hashchange:


          Munchkin.munchkinFunction('clickLink',{href: document.location.hash});


Take note that if you use standard <a> tags and your hrefs ​do not ​start with hashes, then Munchkin will already be attached to them, so you definitely do not want to attach again.

Your question is actually overbroad because you have not specified how your single-page site actually works.  There's no one way to use Ajax for content replacement.