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:
- url - URL of tracker service. URL is removed from public package for privacy/security concerns.
- 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
- 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.
- 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
- eventName - name of the event that triggered this send function. Examples: pageView, cartCheckedOut, addedWishlist
- 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