Skip to content
This repository was archived by the owner on Mar 5, 2019. It is now read-only.

DVS-devtools/js-analytics

Repository files navigation

js-analytics

[!!!] The source code of this package is on https://github.com/docomodigital/js-utils, this repository will be removed asap

Build Status Coverage Status npm version Greenkeeper badge

js-analytics is a interface for Google Analytics to tracking events, pageviews and custom dimensions

Usage

import JsAnalytics from '@docomogital/js-analytics'
// init JsAnalytics and set 'User' custom dim to slot #3 and 'Valuable' to slot #4
JsAnalytics.init({
	enabled: true,
	/* if you pass analyticsID, analytics-adapter call ga('create') for you */
    analyticsID: 'UA-123456789-1',
	logger: console,
	dimensions: {
		User: 3,
		Valuable: 4
	}
});

// set 'User' custom dim, without re-specify the slot
JsAnalytics.setDimension({
	User: 'logged'
});

// track pageview
JsAnalytics.trackPage({
	page: '/home',
	title: 'Home Page',
	dimensions: {
		Valuable: false
	}
});

// track event
JsAnalytics.trackEvent({
	category: 'Social',
	action: 'Click',
	label: 'Facebook',
	value: 3,
	dimensions: {
		Valuable: true
	}
});

Installation

NPM

npm install --save @docomogital/js-analytics

Documentation

To read documentation, go to:

http://docomodigital.github.io/js-analytics/latest

About

Interface for Google Analytics to tracking events, pageviews and custom dimensions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •