cli-analytics

1.0.1 • Public • Published

CLI Analytics

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.

Google Analytics Setup

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(...)

Getting Started

Quick Start

Universal Analytics Default Implementation:

const analytics = require('cli-analytics')(tracking_id, options);
analytics.track.event('Category', 'Action', 'Label', 'Value').send();

CLI Analytics Specific Methods

  • startTimer(name) - Instantiates a timer

  • getTimeDiff(name) - Returns the elapsed time of a specific timer in milliseconds.

Examples

Timeout Example, Display elapsed time after waiting 1 second
analytics.startTimer('timeout');
setTimeout(() => {
  console.log(analytics.getTimeDiff('timeout'));
}, 1000);
Normal Use Case Example, Get the time difference for the user selection.
analytics.startTimer('user-selection');
// ... User Selects Options ...
const timing = analytics.getTimeDiff('user-selection');
analytics.track.timing('User Selection', 'Panel 1', timing).send()

Readme

Keywords

none

Package Sidebar

Install

npm i cli-analytics

Weekly Downloads

2

Version

1.0.1

License

ISC

Last publish

Collaborators

  • smacpherson64