Track jQuery AJAX Requests within Adobe Analytics

There is a quick and easy way to track all jQuery AJAX request within an application and have that data sent over to Adobe Analytics. The code automatically logs all jQuery requests occurring within the application, so please continue on to learn how you might be able to take advantage of this.

This solution will capture all request including $.get(), $load(), $post and $ajax(). The solution below needs to be added to the page itself or within an included JS file:

(function ($) {

// Log all jQuery AJAX requests to Adobe Analytics
$(document).ajaxSend(function(event, xhr, settings){
s.linkTrackVars = “propXX, events”;
s.linkTrackEvents = “eventXX”;
s.propXX = event+”|”+settings.url;
s.events = “eventXX”;
s.tl(‘this’,’o’,”AJAX request logged”);

});

})(jQuery);

That’s it! With this in place you can now track all AJAX request within Adobe Analytics leveraging jQuery.