(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 (err, resp) {
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 (err, resp) {
if (!err && resp.statusCode === 200) {
console.log('Page has been tracked with Google Analytics');
}
});
NA.trackEvent('test event', 'boom', function (err, resp) {
if (!err && resp.statusCode === 200) {
console.log('Event has been tracked with Google Analytics');
}
});
NA.setProxy('http://your.proxy.com', 'title', function (err, resp) {
NA.trackEvent(...);
});
The answers, as per usual, can be learned from the Google: https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting#gifParameters