Search code examples
ajaxgoogle-analyticsgoogle-analytics-apiweb-analyticspageviews

Use events or virtual pageviews for Google Analytics and ajax


What makes more sense (or is proper according to google)? Registering an event or a virtual pageview with Google Analytics when tracking navigation through a webpage with heavy use of ajax?

I had been using events to track this kind of thing, but I find myself kind of emulating the pageview mechanism by tracking the clicks through events like the following:

_gaq.push(['_trackEvent', 'signup', 'clicked', 'header']);

should I instead be creating virtual pageviews when visitors click on links that call AJAX and bring up dynamic content?

_gaq.push(['_trackPageview', '/signup/form']);

Solution

  • If this is a new content that user navigates to, then you should be using virtual pageviews.

    If you use events for all navigation then some metrics will be unreliable like pages/visit, avgTimeOnPage, avgTimeOnSite, pageDepth. If you use pageviews for navigation these metrics will be closer to the truth.