Google Analytics has a fresh & nice feature that Ajax & Flash developers will like. Yes, it is now possible to track pageviews in Ajax & Flash applications. And, it is simple.

It is enough to call a function named _trackPageview when an Ajax request or Flash event is called.

Google Analytics Ajax - Flash Tracking

An example provided by Google is:

...
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);
      pageTracker._trackPageview("/pagefilename1" ); } 
   else {
      alert('Error.');
   }
}
}
...

To summarize, after an Ajax request is made, the function is called with the page name that is viewed. And, Analytics tracks this page name.

An important usage tip about this feature is that, Google Analytics codes are normally installed just before the </body> tag. When calling _trackPageview function, you’ll need to use it after the Analytics codes are included. Which means installing the Analytics codes just after the <body> tag is a guaranteed solution.

Google is presenting detailed info & examples for both Ajax & Flash.

P.S. The feature is only available with the new Analytics code: the gaJsHos one.

WebResourcesDepot Feed