Skip to content

Commit

Permalink
#24 - improving tracking logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Feb 20, 2013
1 parent 196145f commit 442d035
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/app.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
initialize: function(){
_.bindAll(this, 'fb_fix');
// include this in your router if using Google Analytics
// this.bind('all', this._trackPageview);
// analytics
this.bind('all', this._trackPageview);
},
// Save app state in a seperate object
state: {
Expand All @@ -29,7 +29,8 @@
// Utils
_trackPageview: function(){
var url = Backbone.history.getFragment();
if( !_.isUndefined( _gaq ) ) _gaq.push(['_trackPageview', "/#"+url]);
// check for Google Analytics
if( typeof _gaq != "undefined" ) _gaq.push(['_trackPageview', "/#"+url]);
}

});
Expand Down
2 changes: 1 addition & 1 deletion lib/app.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
e.preventDefault();
var url = this.findLink(e.target);
// track the click with Google Analytics (if available)
if( !_.isUndefined(pageTracker) ) url = pageTracker._getLinkerUrl(url);
if(typeof pageTracker != "undefined") url = pageTracker._getLinkerUrl(url);
window.open(url, '_blank');
return false;
},
Expand Down

0 comments on commit 442d035

Please sign in to comment.