CLI Analytics
is intended to allow quick integration from the cli into analytic interfaces. Starting with version 0.0.1, CLI Analytics interfaces with Google Analytics.
- CLI Analytics uses Universal Analytics as its interface to interact with the Measurement Protocol of Google Analytics.
When CLI Analytics is instantiated, it maps the Universal Analytics object to the track object with options sent in through the constructor. Below is an example of how to utilize Universal Analytics.
const analytics= require('cli-analytics')(tracking_id, options);
analytics.track.event(...)
analytics.track.pageview(...)
analytics.track.timing(...)
Universal Analytics Default Implementation:
const analytics = require('cli-analytics')(tracking_id, options);
analytics.track.event('Category', 'Action', 'Label', 'Value').send();
-
startTimer(name)
- Instantiates a timer -
getTimeDiff(name)
- Returns the elapsed time of a specific timer in milliseconds.
analytics.startTimer('timeout');
setTimeout(() => {
console.log(analytics.getTimeDiff('timeout'));
}, 1000);
analytics.startTimer('user-selection');
// ... User Selects Options ...
const timing = analytics.getTimeDiff('user-selection');
analytics.track.timing('User Selection', 'Panel 1', timing).send()