This package has been deprecated

Author message:

Kentico Cloud Tracking API has been removed and therefore this library is now obsolete

kentico-cloud-tracking
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Kentico Cloud Tracking SDK

A client library for manually tracking visitor data with Kentico Cloud in Node and browsers. Abstracts calls to the Kentico Cloud Tracking API. For more information, see the Tracking API Reference.

The library supports ES2015 and is fully written in TypeScript.

Installation

npm i rxjs --save
npm i kentico-cloud-tracking --save

Initialization

import { TrackingClient } from 'kentico-cloud-tracking';
 
const client = new TrackingClient({
    projectId: 'xxx',
);

Usage with RxJS (recommended)

We strongly recommend using Observable instead of Promise as observables support all that Promises too, and much more. Using Observables is especially important if you are building any modern application (for example, single page apps with React or Angular) as it allows you to easily cancel, merge, flatten or retry requests.

After creating a subscription, don't forget to unsubscribe when you don't need the result anymore (for example, when navigating to a different page).

// Starts a new session
client.recordNewSession({
    sid: '111114cc62300000',
    uid: '1111136b4af00000',
})
    .getObservable()
    .subscribe();
    
// Record a custom activity
client.recordCustomActivity({
    sid: '111114cc62300000',
    uid: '1111136b4af00000'
  }, 
"Clicked_facebook_icon")
  .getObservable()
  .subscribe();
 
 
// Creates a contact profile
client.createContactProfile({
  sid: '111114cc62300000',
  uid: '1111136b4af00000',
  email: "john.snow@wall.north",
  name: "John Snow",
  company: "Night's Watch",
  phone: "444-256-487",
  website: "http://gameofthrones.wikia.com/wiki/Jon_Snow"
})
  .getObservable()
  .subscribe();

Usage with Promise

For whatever reason, you can still use good old Promises:

client.recordNewSession({
    sid: '1111136b4af00000',
    uid: '111114cc62300000',
})
    .getPromise()
    .then();

Client configuration

Property type description
projectId string ProjectId of your Kentico Cloud project
enableAdvancedLogging boolean Indicates if advanced (developer's) issues are logged in the console. Enable for development and disable in production.
baseUrl string Can be used to configure custom base URL (e.g., for testing)
retryAttempts number Number of retry attempts when an error occurs. Defaults to '3'. Set to '0' to disable.

Dependencies (1)

Dev Dependencies (27)

Package Sidebar

Install

npm i kentico-cloud-tracking

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

2.22 MB

Total Files

408

Last publish

Collaborators

  • enngage