This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/page_tracking.js
Robin Ward b617468098 FIX: currentPath was not changing when transitioning to the same path.
Added a new hook to allow other kinds of analytics.
2014-01-13 15:30:56 -05:00

16 lines
388 B
JavaScript

/**
Sets up the PageTracking hook.
**/
Discourse.addInitializer(function() {
var pageTracker = Discourse.PageTracker.current();
pageTracker.start();
// Out of the box, Discourse tries to track google analytics
// if it is present
if (typeof window._gaq !== 'undefined') {
pageTracker.on('change', function() {
window._gaq.push(['_trackPageview']);
});
}
});