« Icon-based and tree-format dialog boxes with CFTREE and CFLAYOUT | Main | A CFCALENDAR replacement to let you select months or weeks »

How do you get Google Analytics to track AJAX requests?

An interesting question came up in conversation during my ride to work this morning: can Google Analytics track users if a site's registration process consists of AJAX calls instead of multiple page requests?

The site in question had spent several thousand dollars on purchasing search keywords through Google Adsense, and wanted to know just how well they were spending their money. But the site was having difficulty tracking user's clicks because their registration process (in fact, almost their whole site) consisted of a single page and a whole lot of snazzy AJAX calls. Frankly, it was a pretty cool interface-- but it made tracking cost per acquisition and ROI almost impossible, because the only clicks that Google Analytics were capturing were from the initial homepage request. All off the AJAX interactions, which constituted the rest of the user's activity on the site, were going unmeasured.

So this problem piqued my curiosity, and I researched it in Google Analytic's help section. It turns out that there is a solution: like I thought, you just insert a call to one of Google's javascript functions in your AJAX code. Effectively, this means you perform an additional AJAX call to Google Analytics before making the AJAX call to your own site.

Has anyone else experienced this problem and/or found a different solution?

The specific technique is documented in an article entitled "How do I track AJAX applications?" in Google Analytic's help center.

Post a comment


Type the characters you see in the picture above.