This package has been deprecated

Author message:

WARNING: This package has been renamed. Install google-ua instead; see https://github.com/pirxpilot/google-ua

code42day-ua

1.3.0 • Public • Published

NPM version NPM version

code42day-ua

Google Universal Analytics tracking snippet

Installation

$ npm install -S code42day-ua

API

Activate Google Analytics on the page and track page

require('code42day-ua')("UA-XXXX-X");

Alternatively you can define ua property ID as a data attribute of document body

<body data-ua-property-id="UA-XXXX-X">

Check test/index.html for example.

Optional fields parameter lets you set general tracker fields before the pageview event is sent.

require('code42day-ua')("UA-XXXX-X", {
  anonymizeIP: true,
  forceSSL: true,
  userId: 'as8eknlll'
});
 
// set fields, retrieve property ID from data attribute of document body
require('code42day-ua')({
  anonymizeIP: true,
  forceSSL: true,
  userId: 'as8eknlll'
});
 

You can prevent snippet from sending pageview event automatically by setting the first parameter to false

// initilize tracker, do not send `pageview` event
require('code42day-ua')(false, "UA-XXXX-X")
 
// initialize tracker, do not send `pageview` event, retrieve property ID from data attribute of document body
require('code42day-ua')(false);
 

License

MIT

Package Sidebar

Install

npm i code42day-ua

Weekly Downloads

2

Version

1.3.0

License

MIT

Last publish

Collaborators

  • deprecated.packages