This feature is available only with paid Kochava accounts. Contact us to learn more.
This document describes how to install the SDK using Node.js & NPM (Node Package Manager), which is not specific to any framework.
NOTE: This page describes a generic node integration with the SDK. If you are using a node JavaScript framework, like React, Vue, Angular etc, refer to the Integration documentation for the appropriate framework.
Integrating the SDK
Requirements:
- NodeJS
- NPM
Supported Platforms:
- NodeJS
Data Privacy:
Integration:
The Kochava web SDK is available for Node.js projects as a normal npm package. It provides a class called Kochava, which contains all necessary Kochava SDK functions and behavior.
- As a prerequisite, ensure Node.js and the NPM CLI are set up and ready to use locally. See https://docs.npmjs.com/downloading-and-installing-node-js-and-npm for more information.
- Install the latest Kochava SDK version using one of the following CLI commands:
Globally:npm install -g kochava
Locally:npm install kochava
Local as Dev Dependency:npm install -D kochava
ornpm install kochava --save-dev
For more information on installing packages from the CLI, see: https://docs.npmjs.com/cli/v6/commands/npm-install
Versioning:
The latest SDK version will be installed using the above commands, and we strongly recommend always installing the latest version. However, if you wish to install a specific version, the desired version should be appended to the CLI command. For example, to install SDK version 3.0.1 the CLI command might look like this: npm install kochava@3.0.1
Starting the SDK
The location of the start call can vary widely depending on how your Node project is set up and configured, but as a general rule, try to place this call in whatever context represents the start of your web page.
Once you have added the Kochava SDK to your project, the next step is to create and start the SDK class in code. Only your App GUID is required to start the SDK with the default settings, which is the case for typical integrations.
Kochava recommends starting the SDK as soon as the application starts, although this can be done later if needed. Starting the tracker as early as possible will ensure it is started before use, resulting in more accurate data/behavior.
Where your web page starts:
- Import the Kochava class.
- Create an instance of the Kochava class (we recommend calling it lower-case ‘kochava’).
- (Optional) Make any desired pre-start configuration calls (registerIdentityLink, disableAutoPage, useCookies etc).
- Call startWithAppGuid using a valid Kochava App GUID.
// Import Kochava
import { Kochava } from 'kochava';
const kochava = Kochava.create();
// Optional pre-start calls would go here
kochava.startWithAppGuid("YOUR_APP_GUID");
Optional Configuration
From here on, the SDK is integrated and ready, the following configuration calls are optional, and are only for special desired SDK behavior. The following code snippets should be placed at in the above snippet, at the comment labeled Optional pre-start calls will go here
.
Call this function with an argument of true to stop the SDK from automatically signaling a page event when the SDK starts.
// Import Kochava
import { Kochava } from 'kochava';
const kochava = Kochava.create();
// Auto pages will be sent (default)
kochava.disableAutoPage(false);
// Auto pages will not be sent
kochava.disableAutoPage(true);
kochava.startWithAppGuid("YOUR_APP_GUID");
Call this function with an argument of true to drop the Cookie on the website to track a device across sub-domains.
// Import Kochava
import { Kochava } from 'kochava';
const kochava = Kochava.create();
// Will not use cookies (default)
kochava.useCookies(false);
// Will use cookies
kochava.useCookies(true);
kochava.startWithAppGuid("YOUR_APP_GUID");
Confirm the Integration
Where to Go From Here:
Now that you have completed integration you are ready to utilize the many features offered by the Kochava SDK. Continue on to Using the SDK and choose a topic.