platforms-up-tracking-sdk

1.0.0 • Public • Published

https://bitbucket.org/oandacorp/platforms-up-tracking-sdk

Tracking SDK

This SDK provides a set of functions for tracking user interactions and events in a web application. It allows you to identify users, track events, and record page views. The SDK supports multiple environments such as development, UAT, staging, and production.

Table of Contents

Development

npm install

npm start - will start webpack dev server with empty html page. Methods will be available in window.UPTracking object. You can test functionality by invoking them in console: window.UPTracking.track(...)

Usage

Setting the Environment

Set the environment to determine which URL will be used for making requests. The environment can be set to dev, uat, stage, or production.

setEnvironment("production");

Getting the Environment

Retrieve the current environment setting.

const currentEnv = getEnvironment();
console.log(currentEnv); // Output: production

Getting the Tracking ID

Get the tracking ID from the cookies.

const trackingId = getTrackingId();
console.log(trackingId); // Output: trackingId value or null if not set

Page

You can call page method with optional params like: tracking ID, title, path, name, and url If you didn't pass tracking ID, a one will be generated and stored in cookies. title, path, and url are gathered by default.

page({
  trackingId: "1234-2382-2494-2948",
  title: "Product Page - Widget",
  path: "/products/widget",
  url: "http://example.com/products/widget",
  name: "Product",
});

Identify User

Send an identify request with email and tracking ID.

identify({
  email: "",
  trackingId: "",
});

Track Event

To send a track request to log a specific event, provide an event name and an object containing oneId or trackingId along with any other properties you want to add to this event. These properties will appear inside the segment event.

If neither oneId nor trackingId is provided, the trackingId will be read from cookie if it's available there.

Example of event tracking with payload:

// Event tracking with payload
track("orderAdded", {
  price: 11,
  oneId: "bb7ac001-aeb7-11ed-a68f-42010adc0047",
});

or

// Event tracking with payload
track("orderAdded", {
  price: 11,
  trackingId: "ae5ac001-aeb7-11ed-a68f-42010adc0047",
});

/platforms-up-tracking-sdk/

    Package Sidebar

    Install

    npm i platforms-up-tracking-sdk

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    30.1 kB

    Total Files

    30

    Last publish

    Collaborators

    • oanda-api