nodealytics

Google Analytics API for Node projects

Nodealytics

(Formerly Googalytics)

Simple node module to send custom server-side events to Google Analytics

Heavily influenced by the Gabba project from the guys at the Hybrid Group (http://github.com/hybridgroup/gabba)

npm install nodealytics

// initialize 
var NA = require("nodealytics");
NA.initialize('UA-12345678-1', 'someplace.com', function () {
  //MORE GOOGLE ANALYTICS CODE HERE 
});
NA.trackPage('Page Title', '/page/path', function (errresp) {
  if (!err && resp.statusCode === 200) {
    console.log('Page has been tracked with Google Analytics');
  }
});
NA.trackPage('Page Title', '/page/path', {utmr:"http://www.google.com"}, function (errresp) {
  if (!err && resp.statusCode === 200) {
    console.log('Page has been tracked with Google Analytics');
  }
});
NA.trackEvent('test event', 'boom', function (errresp) {
  if (!err && resp.statusCode === 200) {
    console.log('Event has been tracked with Google Analytics');
  }
});
NA.setProxy('http://your.proxy.com', 'title', function (errresp) {
  NA.trackEvent(...);
});

The answers, as per usual, can be learned from the Google: https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting#gifParameters