It's All Writing.

Writing makes you happy.

How to track pageview with Google Analytics in Node app



Normally, in order to track pageview with Google Analytics, it is necessary to embed the tracking code in client-side JavaScript and execute it in the browser.
Therefore, an ingenuity is required in order to perform tracking accompanying the processing on the server side.


At Node app, you can track pageview with using universal-analytics module.
The example is shown as below ( written by TypeScript ).

Above example works on Google Cloud Functions for Firebase.
Each time the same Process function is called, the track which is recorded as accessing /someprocess is sent at Google Analytics.