Wednesday, 3 May 2017

Using Google Analytics with Node.js

I'm running a small website/blog running on a node.js server and I'm trying to implement Google Analytics to track views.

I'm using the universal-analytics npm module to do this.

I initialise like this:

const ua = require('universal-analytics')
const visitor = ua('UA-XXXXX')

When a page is requested I run this:

visitor.pageview("/<pagename>").send();

So far, all I see in my GA dashboard are current active users and it updates quite quickly. However I would also like to be able to view something such as a request count for each page in total over a time period. That is, I would like it to register a user visit and keep it for me to view later. Is this already being done through pageview, or do I need to add something?



via Youssef Sami

No comments:

Post a Comment