Lets say I have a website with a few pages. The purpose of each of those pages is to display live statistics for a real world event (for example, sports scores). Every 60 seconds, an Ajax call is made to the server to fetch the latest sports scores and the update the page with those scores. A user would typically open this webpage and leave it open for many minutes (maybe hours). They would never need to refresh the page because it always has the updated scores on it.

What would be the best way to track my user's experience on this page with Google Analytics. Obviously, when the page first loads, that page visit is logged. But then, every time some Ajax call occurs, what would I have Google Analytics do? I want to properly track time-on-site and page loads. Would each Ajax refresh be considered a new page load?

I've seen some sites suggest doing this when Ajax happens:

_gaq.push(['_trackPageview', '/somepage'])

That would be like telling Google Analytics that the user reloaded the page. Is this accurate? Or is there some other type of event to push that is more accurate for Ajax calls? Technically I guess you could tell GA to track the page view of the Ajax URL? Or would using custom GA events make more sense?

The reason I'm asking is, lets say down the line, some company wants to purchase my website from me. I would want to be able to show them my Google Analytics history and know that the pageviews and time-on-site is calculated accurately. I would not want someone to have a reason to question time-on-site or page views.

If I was using GA events instead of page views for the Ajax calls, would that accurately be taken into account for time-on-site?

Also, if I was running StatCounter on the site at the same time, is there a similar thing I would need to do for that as well?

3 Answers 3


Afaik GA events are your best option.

You could make GA to think there've been changes in the page, but that would mess all the other stats.

You provide AJAX for best user experience. You better redefine your key stats, the key one being not the traditional pageviews but time-on-site. (see Avinash Kaushik for a better explanation: http://www.kaushik.net/avinash/podcast-measuring-rich-media-ajax-flash-flex-rss-blogs/)

I am not sure of this, but if you're asking your user to only read updated data, maybe you could track each AJAX refresh as a download event. Would that make sense to you for the usage of the page? https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide?hl=en


It sounds like the AJAX calls are purely for a data refresh and not based on user activity. I don't think trackPageView or eventTracking are good candidates for reporting. Review how Google calculates time on site / active sessions. Event tracking should be used to track user interaction (stop, play, pause). Track Page view could be possibly used for something like tracking clicks between tabs that dynamically load other page content into a tab.


the event is exelent for this purpose. Pageview will make your statistic not accurate. The session stays the same while more event acquire. Just maybe exlude this event from reports :)

Hit "send event" as you said when ajax reloads the stats or every 1 minute. // Track event ga('send', 'event', 'watching', 'reload'); // ga('send', 'event', 'category', 'action', 'label', 'value');

In TagManager there is also predifind trigger "timer" for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.