Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ridi/event-tracker

Package Overview
Dependencies
Maintainers
9
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ridi/event-tracker

[![npm](https://img.shields.io/npm/v/@ridi/event-tracker.svg)](https://www.npmjs.com/package/@ridi/event-tracker) [![Build Status](https://travis-ci.com/ridi/event-tracker.svg?branch=master)](https://travis-ci.com/ridi/event-tracker)

  • 0.10.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

@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.pixelIdtrue`stringArray`
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

FAQs

Package last updated on 09 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc