You need to enable JavaScript to run this app.
Growth Analysis (Privatization)

Growth Analysis (Privatization)

Copy page
Download PDF
Server Side Access
Node.js SDK
Copy page
Download PDF
Node.js SDK

DataFinder provides you with Node.js SDK, which is convenient for you to perform event tracking on some non-web pages, such as Chrome plugins for event tracking and other scenarios. This article provides you with a hands-on guide to Node.js SDK integration.

Preparation

Get Appid

Before starting the integration, you first need to have an application in the group. Before integrating the SDK, you need to obtain the appid, app key, schema and other information of the corresponding application.
In the privatization scenario, you can view your appid, app key, and schema in "Project Center" - > "Project Management" - > "Project Details" - > "Access to the application" - > "Application ID". For details, please refer to Project Details and Application List.
Image

Get the reporting address

In the private deployment scenario, you need to obtain the data upload address for your own planning and configuration when deploying a private environment. If you do not know this address, please contact your project manager or customer success manager.

Integrated SDK

Step1: Install the SDK

npm i @datarangers/sdk-node 
npm i @datarangers/node-plugin-http

Step2: Initialize the SDK

import { DataRangersSDK } from "@datarangers/sdk-node"; 
import { httpPlugin } from '@datarangers/node-plugin-http'; 

const sdk = new DataRangersSDK({ 
    app_id: 1234, //Pass the appid of the applied item, which must be a number.
    logLevel: "verbose", //Turn on local chronology printing, the default value is silent
    }); 

Parameter

Configuration instructions

app_id

Configure the app ID that is generated when you create an app on the DataFinder, see the Get Appid section above for details.

logLevel

To configure whether to enable local log printing, the enumeration values are as follows.

  • "Verbose": full print
  • "Error": only the error message is printed
  • "Silent" (default): does not print the date

Step3: Set the data reporting address

After initializing the SDK, you need to set the data reporting address before you can report event tracking.

sdk.use(
   httpPlugin(
     {
        channel_domain: "https://***.****.com" //Set up the reporting domain name. In a privatization environment, you need to contact the project manager to obtain the data reporting address.
     }
   )
);

Step4: Set public properties

When you need to set the login ID, or when there are global public properties, you can use config for configuration.

sdk.config({
  user: {
    user_unique_id: "xxx", //Set the global user uuid
  },
  header: {
      os_name: 'xxx', //Set and modify public properties
  },
  custom: {
      key: 123 //Set custom public properties
  }
});

Step5: Reporting event tracking

Report single event tracking

//event tracking
sdk.collect(
  "event_1", //event tracking name
  {
    event_param_a: 123,   //event tracking properties
  }
);

Bulk event tracking

Batch report event tracking, that is, pass in a buried array.

//Bulk reporting event tracking
sdk.collect([
  {
    name: "event_2",
    params: {
      event_param_b: 234,
    },
  },
  {
    name: "event_3",
    params: {
      event_param_c: 567,
    },
  },
]);
Last updated: 2026.08.25 11:56:04