public
Created

How to use node-ga with routes instead of as a middleware. Based on the third example from http://expressjs.com/api#app.VERB ("Several callbacks may also be passed, useful for re-using middleware that load resources, perform validations, etc.")

  • Download Gist
node-ga-routes.js
JavaScript
1 2 3 4 5 6
var ga = require('node-ga')('UA-XXXXXXXX-Y', { safe: true});
/* your usual express options */
 
app.get('/logged-route', ga, LoggedRouteHandler);
app.get('/non-logged-route', NonLoggedRouteHandler);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.