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
After integrating the SDK and adding the code to start the measurement client, launch and run the app for at least 10 seconds or more. During this time the client will start and send an install payload to Kochava. To confirm integration was successful, visit the app’s Install Feed Validation page Apps & Assets > Install Feed Validation. On this page you should see one of two integration messages, indicating integration success or failure.
Integration Successful:
Along with this message you will also see a variety of data points associated with the device used for testing. At this point your integration is successful and you can proceed to the next step(s).
NOTE: It may take a few minutes for the first install to appear within the Install Feed Validation page. If you do not see this message immediately, you may simply need to wait a few minutes and check again.
Integration Not Complete:
If you encounter this message, please review the integration steps, uninstall and reinstall the app, and check again.
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.