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

@rentpath/event-tracker

Package Overview
Dependencies
Maintainers
11
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rentpath/event-tracker

Capture and deliver user events.

  • 7.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
11
Weekly downloads
 
Created
Source

EventTracker

A library for capturing and distributing event tracking data.

Installation

$ npm i --save 'rentpath/event-tracker'

Usage

Create a new EventTracker instance, specifying which providers, trackers, and reducers to use.

const tracker = EventTracker.create({
  providers: [
    ['Tealium', { env: 'dev', account: 'acme', profile: 'primary' }]
  ],
  trackers: [
    'Click',
    'Select'
  ],
  reducers: [
    'Session',
    'Element'
  ]
})

API

EventTracker.create(config)

Creates a new tracker instance.

const tracker = EventTracker.create({ ... })
tracker.track(action, [props])

Records a custom user action.

tracker.track('user_registration', { userId: 123 })
tracker.view([props])

Records a page view action.

tracker.view({ page: 'home' })
tracker.include(props, merge = true)

Attaches additional data to every subsequent tracking event. Data is merged by default if called multiple times, unless the merge argument is false, in which case any existing data is overwritten. Note: data does not persist between separate page loads.

tracker.include({ browser: 'Chrome' })

Configuration

Each EventTracker instance needs to be configured to use at least a single provider, and optionally trackers and/or reducers.

Providers

Providers are 3rd party tag analytics services that offer custom event tracking, such as Tealium, Google Tag Manager or Adobe. In the context of EventTracker they are implemented as proxy adapters to the API's offered by each service.

Tealium

Tealium is a real-time data platform and tag management service. It is the only provider currently supported natively by EventTracker.

Options
OptionTypeDefaultDescription
envstringdevThe TealiumIQ environment. Options are dev, 'qa', prod.
accountstringundefinedThe TealiumIQ account name.
profilestringundefinedThe TealiumIQ profile name.
GoogleTagManager

GoogleTagManager is a real-time data platform and tag management service.

Options
OptionTypeDefaultDescription
gtmIdstringundefinedTag Manager Id.
dataLayerobject{}Default dataLayer values
authstringundefinedauthentication for the container
previewstringundefinedpreview id for the container

Trackers

Trackers are observers that listen for native DOM events, and record corresponding tracking actions. The following trackers are currently supported:

View

Records a view action on page load (DOMContentLoaded).

Click

Records a click action on all native click events.

Select

Records a select action on all native change events.

Form

Records a submit action on all native submit events.


Reducers

Named after the reduce method found in many programming languages, reducers are utilities for adding additional information to each tracking event that gets dispatched. They are called reducers because they are implemented as functions that receive the data payload as an argument, and whatever they return gets sent to the provider adapter. The following reducers are currently supported:

Device

Adds information about the device being used.

Provided Data
FieldDescription
screen_typeThe type of device being used, determined by screen size.
screen_resolutionThe device screen size.
operating_systemThe device operating system.
Options
OptionTypeDefaultDescription
breakpointsobject{ mobile: 0, tablet: 768, desktop: 1024 }An object whose keys represent screen types, and values represent breakpoint thresholds.
Browser

Adds information about the browser being used.

Provided Data
FieldDescription
browserThe browser type (e.g. Chrome)
browser_sizeThe browser size (width x height)
browser_versionThe browser version
Request

Adds information about the current page request.

Provided Data
FieldDescription
urlThe url of the current page.
pathThe pathname of the current url.
hashThe url hash.
domainThe current domain.
query_stringThe query string on the current url.
Meta

Adds data collected from meta tags.

Options
OptionTypeDefaultDescription
filterstringnullA DOM selector used to filter which meta tags to use.
Session

Adds session/visitor ID.

Options
OptionTypeDefaultDescription
visitorKeystringrp_visitor_idThe name of the cookie used to store the visitor ID.
sessionKeystringrp_session_idThe name of the cookie used to store the session ID.
visitorAgeint86400 * 365 * 5 * 1000 (5 years)The expiry age of the visitor cookie in milliseconds.
sessionAgeint30 * 60 * 1000 (30 minutes)The expiry age of the session cookie in milliseconds.
Provided Data
FieldDescription
visitor_idThe unique ID used to identify a user.
visit_idA unique ID used to identify a user session.
Element

Adds data collected from data tags placed on DOM nodes associated with native events (e.g. click events).

Options
OptionTypeDefaultDescription
tagPrefixstringdata-tag_The beginning part of the node attribute used to extract data.
TagManagerEvent

Adds data collected from data tags and transforms to GTM specific KVP's (e.g. click events).


Event

Adds information extracted from event objects.

Provided Data
FieldDescription
x_coordinateThe mouse position relative to the left edge of the document for click events.
y_coordinateThe mouse position relative to the top edge of the document for click events.

Development

Scripts
  • npm run compile - Compiles the module to disk (~/lib).
  • npm run compile:watch - Same as npm run compile but watches files for changes.
  • npm run lint - Lints all files.
  • npm run lint:fix - Lints all files and attempts to fix any issues.
  • npm run test - Runs unit tests.
  • npm run test:watch - Same as npm test but watches files for changes.
  • npm run test:cov - Generates a test coverage report.
Distribution

Execute one of the following commands

npm version patch -m "bump to %s"
npm version minor -m "bump to %s"
npm version major -m "bump to %s"

FAQs

Package last updated on 11 Apr 2019

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