1.0.1 • Published 2 years ago

datalabs-trx-react v1.0.1

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

datalabs-trx-react

Getting started

$ npm install datalabs-trx-react --save

Mostly automatic installation

$ react-native link datalabs-trx-react

Quick Usage

import TrxReact from 'datalabs-trx-react';

const trx = new TrxReact();
trx.init('https://trx-sample-domain.com/', 'TRX-SAMPLEUNIQUECODE');

// tag this page
trx.tag("pageType", "sample-page");  // tag this page as a sample page

// add multiple tags for different type of information as needed
trx.tag('userID', '100');

// send event to tracker with simple dataset
trx.send('loaded', {pagename: 'sample'});

Methods

init

Initialize the tracker by setting the tracking service URL and the site/application identity.

Usage: init(<trackerURL>, <siteIdentifier>)

Parameters:

  1. url - URL of tracker service. URL is removed from public package for privacy/security concerns.
  2. site identifier - A unique site/application identifier that is provided by tracking service admins.

tag

Tags the user or page being viewed. This tag will persist throughout the lifetime of the class instance. Using the same tagName multiple times overwrites the old values assigned to that tag.

Usage: tag(<tagName>, <tagValue>)

Parameters

  1. tagName - Any key you want to tracker to keep track of. This could be page/view related information or user related information. Examples: userID, sessionID, pageType, pageID.
  2. tagValue - Any value for the tag names specified.

send

Sends the data to the tracking service. Should be triggered by events.

Usage: send(<eventName>, <eventDetails>)

Parameters

  1. eventName - name of the event that triggered this send function. Examples: pageView, cartCheckedOut, addedWishlist
  2. eventDetails - javascript object/hash map that provides contextual information about the event that triggered this function. Examples: {pageID: 199, pageURL: 'someURL'} or {transactionID: 839}

Development

# login to user account that has access to the npm module
npm login

# publish the package
npm publish
1.0.1

2 years ago

1.0.0

2 years ago