Background

AJAX is a technique allowing the content a webpage to update without requiring a full reload. 

Sites using AJAX  to display new content are tracked correctly by the standard Narratiive tag when a page is loaded, however they may be under-represented in the page view count. This is because the standard Narratiive tag records a page view during the page load process.  The tag does not, by default, record a page view for AJAX calls after the page has loaded. 

Narratiive provides functionality to register AJAX content requests as page views.

Implementation

Providing the Narratiive tag is inserted correctly on applicable webpages, the client can include a call to the Narratiive AJAX function (see below) in their own AJAX code.

_em.trackAjaxPageview("optional_page_url_or_label");

http_request.onreadystatechange = sendAlert;
http_request.open('GET', url, true);
http_request.send(null);

function sendAlert() {
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      alert(http_request.responseText);
      _em.trackAjaxPageview("http://www.examplesite.com/path");
    }
  else {
    alert('Error.');
  }
}

Once this has been setup, you should be able to see a call to the Narratiive servers with each AJAX content request. This can be confirmed using a web developer tool to track the requests as they occur.

If you have any questions, please contact help@narratiive.com.

Did this answer your question?