Overview

The credoSDK for Web is a JavaScript library designed to capture and track the user behaviours on the web page together with the user’s digital footprint and upload it to the credolab's web-service for future processing of scores and fragments. 

The diagram below shows the overview of how your website can work with the credoSDK for Web:

How will your website work with credoSDK for Web


Standard flow for mobile:
1. Initialize credoSDK for Web
2. Collect credolab dataset
2.1  Get an authorization token via provided Authkey
2.2 Upload credolab dataset to credolab's server
3. Login via user credentials
4. Get credolab score

This is the list of data that can be collected via the credoSDK for Web: 

HTML Table Generator
Category Total Fields Definition
Behavioral Data 19  Metadata related to the user's behaviour on the website. We collect 3 event type categories: keyboard, input, and pointer event. For each user’s action corresponded event type is recorded with time, event details (key type, mouse coordination), input details (if any), and element info describing the DOM
Browser Info 84  Metadata related to the user's browser/device information such as operating system, browser type, and screen details
DOM Metadata related to Document Object Model. This information describes all available objects on the webpage (input fields, buttons, etc)
General Info Metadata related to the sdk and other miscellaneous details such as data collection time, sdk version

credolab provides a script for you to embed on your website. The components loaded by the script are dynamically generated and therefore not included within the script provided nor should they be directly included on your page.


Download

For integration, you should refer to the credoappsdk.js.
Please download the file here.

Integration Guideline

How to integrate the webSDK into your website

Preconditions

Preconditions

  1. Obtain a unique credoapp authentication key from credolab Representative(s) and use it during the data collection process. If you sign up via website, credolab Representative(s) will send you the authentication key 1-3 days upon sign up.
  2. Download the webSDK (JS file) from credolab.

Integrate credoSDK to your Website

Include the credoapp SDK (credoappsdk.js) file into your project.

How to use the credoapp SDK

To start working with the credoapp SDKfirstly you will need to create the instance either CredoppService or CredoAppServiceAsync. The detailed description is below.


CredoAppService
- the instance of credoappSDK that captures behavioural data along with the user’s digital footprint from the browser and uploads it to the credolab web-service once the stopTrackingAndCompleteAsync method is called.   


Basic methods:

  • startTracking The method is intended to start the tracking of user behaviour on the page where the credoapp SDK is integrated.
  • stopTracking The method is intended to stop the tracking of user behaviour on the page where the credoapp SDK is integrated.
  • stopTrackingAndCompleteAsync This method is intended to stop the tracking, collect data from the browser and upload it to the credolab web-service along with behavioral data.


CredoAppServiceAsync - the instance of credoapp SDK that captures behavioral data along with the user’s digital footprint from the browser and continuously uploads it to the credolab web-service. This SDK instance allows capturing behavioral data from different devices by associating with a single reference number. The data is captured and uploaded to the server once every 10 seconds.


Basic methods:

  • startTrackingAsync The method is intended to start the tracking of user behaviour and continuously upload it to the credolab server. 
  • stopTrackingAsync The method is intended to stop the tracking of user behaviour on the page where the credoapp SDK is integrated.

stopTrackingAndCompleteAsync This method is intended to stop the tracking and complete collection process.

An example of CredoAppService usage:



<!doctype html>
<html>
<head>
  <title>Demo integration page</title>
  <script language="javascript" src="credoappsdk.js"></script>
</head>
<body>
  <p>By clicking on the button below you will collect and upload dataset to CredoLab server</p>
 <button onclick="stopTracking()">Stop</button> 
 <button onclick="collectData()">Collect</button>
 <script>
// CredoApp authentication key provided by CredoLab team
var authKey = "*************";
// value from CredoLab URLs table
var url = "https://scoring-sales.credolab.com";
// reference number intended to associate collected dataset with record on lender side
var referenceNumber = "************";
var credoAppService = new credoappsdk.CredoAppService(url, authKey);
credoAppService.startTracking();
 
function stopTracking() {            
credoAppService.stopTracking()
}
 
    function collectData() {            
credoAppService.stopTrackingAndCompleteAsync(referenceNumber).then(() => {
	alert(“Dataset has been uploaded and completed”);
}, (e) => alert(e));
    }
  </script>
</body>
</html>



An example of CredoAppServiceAsync usage:


<!doctype html>
<html>
<head>
  <title>Demo integration page</title>
  <script language="javascript" src="credoappsdk.js"></script>
</head>
<body>
  <p>By clicking on the button below you will collect and upload dataset to CredoLab server</p>
  <button onclick="stopTracking()">Stop</button>
  <button onclick="collectData()">Collect</button>
  <script>
// CredoApp authentication key provided by CredoLab team
var authKey = "*************";
// value from CredoLab URLs table
var url = "https://scoring-sales.credolab.com";
// reference number intended to associate collected dataset with record on lender side
var referenceNumber = "************";
var credoAppService = new credoappsdk.CredoAppServiceAsync(url, authKey);
credoAppService.startTrackingAsync(referenceNumber).then(() => {
	alert(“Event tracking started and dataset continuously uploaded”);
}, (e) => alert(e));
 
function stopTracking() {            
credoAppService.stopTrackingAsync().then(() => {
	alert(“Event tracking stopped”);
}, (e) => alert(e));
    }
 
    function collectData() {            
credoAppService.stopTrackingAndCompleteAsync().then(() => {
	alert(“Dataset has been completed”);
}, (e) => alert(e));
    }
  </script>
</body>
</html>


Credoapp API Description

Credoapp Service

credoappsdk.CredoAppService

CredoAppService enables the tracking of the user behavior and the capture of a user’s digital footprint. Uploads data to the credolab web-service for the future processing of scorecard and fragment.


Class constructor

Description:

Create an instance of the CredoAppService with a target configuration.


Signature:


CredoAppService(url, authKey)

Parameters

Name Description Type
url The URL of credolab service.  string 
authkey  An authentication key can be obtained from the credolab team.  string 

Methods

startTracking

Description:

The method is intended to start the tracking of user behaviour on the page where the credoapp SDK is integrated.


Signature:


startTracking()


stopTracking

Description:

The method is intended to stop the tracking of the user behaviour on the page where the credoapp SDK is integrated.

Signature:


stopTracking()

stopTrackingAndCompleteAsync

Description:

This method is intended to stop the tracking, collect and upload data to the credolab web-service. Returns a promise.


Signature:


stopTrackingAndCompleteAsync(referenceNumber):Promise

Parameters:

Name Description Type
referenceNumber Unique identifier intended to associate dataset, uploaded to credolab web-service, with a record on the lender side. (The max length of 100 characters). String

Returns:

Type Description
Promise Promise result contains object that represents the eventual completion (or failure) of an asynchronous operation. If an error occurs CredoAppException will be passed to the failure with error details.

Credoapp Service Async

credoapp.CredoAppService

CredoAppServiceAsync enables the tracking of the user behaviour data and the capture of a user’s digital footprint from different devices and continuously uploads it to the credolab web-service  for the future processing of scorecard and fragment.


Class constructorMethods

Description:

Create an instance of the CredoAppServiceAsync with a target configuration.

Signature:


CredoAppServiceAsync(url, authKey)

Parameters:

Name Description Type
url The url of credolab service. string
authKey An authentication key can be obtained from credolab team. string

Methods

startTrackingAsync

Description:

The method is intended to start the tracking of user behaviour data and continuously upload it to the credolab web server.


Signature:


startTrackingAsync(referenceNumber): Promise

Parameters:

Name Description Type
referenceNumber Unique identifier intended to associate dataset, uploaded to credolab web-service, with a record on the lender side. (The max length of 100 characters). string

Returns:

Type Description
Promise Promise result contains object that represents the eventual completion (or failure) of an asynchronous operation. If an error occurs CredoAppException will be passed to the failure with error detail

stopTrackingAsync

Description:

The method is intended to stop the tracking of the user behaviour on the page where the credoapp SDK is integrated.


Signature:


stopTrackingAsync(): Promise

Returns:

Type Description
Promise Promise result contains object that represents the eventual completion (or failure) of an asynchronous operation. If an error occurs CredoAppException will be passed to the failure with error detail

stopTrackingAndCompleteAsync

Description:

This method is intended to stop the tracking, collect data from the browser and upload it to the credolab web-service along with behavioral data. Returns a promise value.


Signature:


stopTrackingAndCompleteAsync(): Promise

Returns:

Type Description
Promise Promise result contains object that represents the eventual completion (or failure) of an asynchronous operation. If an error occurs CredoAppException will be passed to the failure with error detail


Credoapp Exception

credoappsdk.CredoAppException

This exception is passed to Promise failure result when the credoapp SDK is unable to complete an action.


Methods

getMessage

Description:

Get detailed information about the error that occurred.


Signature:


String getMessage()

getCode

Description:

Get error code.

Signature:


Number getCode()

Member

Members:

credolab informs API clients of both the high-level error class (using the status code) and the finer-grained details of the problem. 

The latest approach is [RFC 7807]-based.

An exception has up to four properties:


Error Codes

Status Code Reason Description
30 Tracking not started successfully startTracking() action has not started correctly due to e.g. reference number provided was expired or completed (the related error has been received earlier)
40 Value is invalid The value is invalid.

Example:
Auth key is invalid
URL is invalid
41  Dataset state is invalid Reference number is not unique Dataset is in complete state Reference number is expired
42 Auth credentials are incorrect or action forbidden The provided credentials don't match. 
50 Server error  Something is wrong with the server. 
90  Unknown error  Unexpected error occured.