attempt at fixing google analytics

This commit is contained in:
Sam Saffron 2013-02-25 08:36:46 +11:00
parent 430a397cde
commit 997b436210
2 changed files with 20 additions and 35 deletions

View File

@ -1,11 +1,22 @@
(function() {
/*global _gaq:true */
window.Discourse.ApplicationController = Ember.Controller.extend({
needs: ['modal'],
showLogin: function() {
var _ref;
return (_ref = this.get('controllers.modal')) ? _ref.show(Discourse.LoginView.create()) : void 0;
window.Discourse.ApplicationController = Ember.Controller.extend({
needs: ['modal'],
showLogin: function() {
var _ref;
return (_ref = this.get('controllers.modal')) ? _ref.show(Discourse.LoginView.create()) : void 0;
},
routeChanged: function(){
if (window._gaq === undefined) { return; }
if(this.afterFirstHit) {
Em.run.next(function(){
_gaq.push(['_trackPageview']);
});
} else {
this.afterFirstHit = true;
}
});
}).call(this);
}.observes('currentPath')
});

View File

@ -1,26 +0,0 @@
/*global _gaq:true */
(function() {
Ember.Route.reopen({
setup: function(router, context) {
var path;
this._super(router, context);
if (window._gaq) {
if (this.get("isLeafRoute")) {
/* first hit is tracked inline
*/
if (router.afterFirstHit) {
path = this.absoluteRoute(router);
_gaq.push(['_trackPageview', path]);
} else {
router.afterFirstHit = true;
}
return null;
}
}
}
});
}).call(this);