0.10.5 • Published 2 years ago

@ridi/event-tracker v0.10.5

Weekly downloads
404
License
MIT
Repository
github
Last release
2 years ago

@ridi/event-tracker

npm Build Status

Provides tracking API that helps to send events to various logging services like Google Analytics, RIDI beacon system

Install

NPM

$ npm install @ridi/event-tracker

Browser

<script src="./node_modules/@ridi/event-tracker/dist/umd/bundle.min.js"></script>

Usage

import { Tracker, DeviceType } from "@ridi/event-tracker";

const tracker = new Tracker({
  deviceType: DeviceType.PC,
  userId: "ridi",
  serviceProps: {
    "prop1": "value1",
    "prop2": "value1"
  },
  beaconOptions: {
    use: true
  },
  gaOptions: {
    trackingId: "UA-XXXXXXXX-X",
    pathPrefix: "/PAPERSHOP",
    fields: {
      contentGroup5: "PAPERSHOP"
    }
  },
  pixelOptions: {
    pixelId: "1000000000"
  },
  tagManagerOptions: {
    trackingId: "GTM-XXXX00"
  },
  kakaoOptions: {
    trackingId: "12345678"
  },
  twitterOptions: {
    mainPid: "a1234",
    impressionPid: "b1632",
    booksSignUpPid: "a1245",
    selectStartSubscriptionPid: "z1253",
  }

});

tracker.initialize();

tracker.sendPageView(location.href);

tracker.sendEvent("Purchased", {
  t_id: "201808180210135",
  value: 29000
});

API

new Tracker(MainTrackerOptions)

MainTrackerOptions

KeyRequiredTypeDescription
debugfalsebooleanDefaults to false If set to true, All fired events are logged to browser via console.log
developmentfalsebooleanRepresents the state of the system environment your application
userIdfalsestringLogged user's identifier.
deviceTypetrueDeviceTypeType of connected user's device. Please refer DeviceType type
servicePropsfalseServicePropAdditional properties related to specific service. Please refer ServiceProp type, which is Record<string, string>
gaOptionsfalseGAOptionsOptions related with Google Analytics tracking module
gaOptions.trackingIdtruestringGA Tracking ID like UA-000000-01.
gaOptions.pathPrefixflasestringPathname prefix for manual content grouping.
gaOptions.fieldsfalseGAFieldsGA configurable create only fields.
beaconOptionsfalseBeaconOptionsOptions related with Beacon tracking module
beaconOptions.usefalsebooleanDefaults to true, Specifies whether to send log data to beacon system
beaconOptions.beaconSrcfalsestringSource of the image to be used as a beacon
pixelOptionsfalsePixelOptionsOptions related with Pixel tracking module
pixelOptions.pixelIdtruestring | Array<string>Facebook Pixel Tracking ID like 1000000000.
tagManagerOptionsfalseTagManagerOptionsOptions related with Google Tag Manager tracking module
tagManagerOptions.trackingIdtruestringGoogle Tag Manager Tracking ID like GTM-XXXX00
gTagOptionsfalseGTagOptionsOptions related with GTag tracking module
gTagOptions.trackingIdtruestringGTag Tracking ID like AW-XXXX00
kakaoOptions.trackingIdtruestringKakao Pixel Tracking ID
twitterOptions.mainTidtruestringTwitter Pixel universal tag type ID
twitterOptions.impressionIdtruestringID of impression event tag

Tracker.initialize()

To use this library correctly, you need to call this method least once either before calling other methods or after.

written event records before calling initialize, this records flush after initialized.

Tracker.sendPageView(href, referrer)

KeyRequiredTypeDescription
hreftruestringe.g https://example.com/path?key=value#hash
referrerfalsestringe.g https://google.com/search?q=example

Tracker.sendEvent(name, data)

KeyRequiredTypeDescription
nametruestringIndicating what the given event is
datafalseobjectData object to be sent with the event. e.g { color: 'red' }

Tracker.set(ChangeableTrackerOptions)

Allow to set (change) MainTrackerOptions's attributes

ChangeableTrackerOptions

KeyRequiredTypeDescription
userIdfalsestring
deviceTypefalseDeviceType

Develop

$ git clone https://github.com/ridi/event-tracker && cd tracking
$ npm install
$ npm run build

Test

$ npm run test

Publish

$ npm run deploy
$ # or
$ npm run build && npm publish --access public

LICENSE

MIT

0.10.5

2 years ago

0.10.4

2 years ago

0.10.3

3 years ago

0.11.0-alpha.7

3 years ago

0.11.0-alpha.6

3 years ago

0.11.0-alpha.5

3 years ago

0.11.0-alpha.4

3 years ago

0.11.0-alpha.2

3 years ago

0.11.0-alpha.3

3 years ago

0.11.0-alpha.1

4 years ago

0.10.2

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.9

4 years ago

0.8.8

4 years ago

0.8.7

4 years ago

0.8.6

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago