@deltax-sdk/cordova-plugin-deltax-mobile-sdk v1.0.1
cordova-plugin-deltax-mobile-sdk
Description
Cordova-plugin-deltax-mobile-sdk is a cordova plugin which allows you to use the DeltaX Mobile SDK in your cordova-based hybrid applications. The support is currently limited to the android platform.
Usage
Get access to plugin:
Plugin will be available in window object once cordova is initialised. You can listen to document ready event and initialise the plugin. In Ionic, you can access it after platform ready.
https://ionicframework.com/docs/utilities/platform#ready-promise-string-
var dxPlugin = {};
if(window && window.DeltaXMobileSDK){
dxPlugin = window.DeltaXMobileSDK;
}
Note: You need to maintain this dxPlugin object. Alternatively, you can skip this step and access the sdk using window.DeltaXMobileSDK. Example: window.DeltaXMobileSDK.initDxTracker('xxxx1234');
Initialise SDK:
initDxTracker(businessProfileEncodedIds, success, failure)
Example:
dxPlugin.initDxTracker( ['xxxx1234', 'xxxx6789'] ,
( ) => {
//Statements to execute on success
},
( ) => {
//Statements to execute on failure
}
);
Note: The first BusinessProfileEncodedId in the first call to initDxTracker is set as the default tracker by the SDK. If you wish to change the default tracker, setDefaultTracker must be called explicitly.
Set Default Tracker Instance:
setDefaultTracker(businessProfileEncodedId, success, failure)
parameter | type | description |
---|---|---|
businessProfileEncodedId | String | Array of business profile encoded ids to initialise trackers |
success | ( ) => void | Success callback - called after successfully setting default tracker (optional) |
failure | (err : Object) => void | Failure callback - called if setting default tracker fails (optional) |
Example:
dxPlugin.setDefaultTracker( 'xxxx6789');
Set Default Customer Id:
Note: This value can be overridden when you're tracking a particular event.
setCustomerId(params, success, failure)
parameter | type | description |
---|---|---|
params | Object | Options and value to be passed |
success | ( ) => void | Success callback - called after successfully setting customer id (optional) |
failure | (err : Object) => void | Failure callback - called if setting customer id fails (optional) |
params
name | type | default | description |
---|---|---|---|
Value | String | Default Customer Id to be set for a specific tracker instance | |
BusinessProfileEncodedId | String | undefined | Id of the tracker for which customer id is to be set. If not passed, default customer id will be set for the default tracker instance |
Example:
// Specify business profile for which property is to be set
var params = {
Value: '123',
BusinessProfileEncodedId: 'xxxx1234'
};
dxPlugin.setCustomerId(params);
// Apply property for default tracker
var params = {
Value: '123'
};
dxPlugin.setCustomerId(params);
Set Default Customer Phone Number and Default Customer Email:
Note: These values can be overridden when you're tracking a particular event.
setCustomerPhoneNumber(params, success, failure)
setCustomerEmail(params, success, failure)
parameter | type | description |
---|---|---|
params | Object | Options and value to be passed |
success (optional) | ( ) => void | Success callback - called after successfully setting customer email/phone number |
failure (optional) | (err : Object) => void | Failure callback - called if setting customer email/phone number fails |
params
name | type | default | description |
---|---|---|---|
Value | String | Default Customer Email / Phone Number to be set for a specific tracker instance | |
BusinessProfileEncodedId (optional) | String | undefined | Id of the tracker for which customer id is to be set. If not passed, default customer id will be set for the default tracker instance |
IsEncoded (optional) | Boolean | false | By default, the SDK assumes the given value is not encoded and encodes it before an event is triggered. If IsEncoded is passed as true, then you are required to pass encoded Customer Email/Phone Number. |
// Specify business profile for which property is to be set
// Since IsEncoded is not passed in params, SDK will encode it
var params = {
Value: 'abcd@xyz.com',
BusinessProfileEncodedId: 'xxxx1234'
};
dxPlugin.setCustomerEmail(params);
// Since IsEncoded is set to true, SDK expects encoded value to be passed
var params = {
Value: '52baew13c1',
IsEncoded: true,
BusinessProfileEncodedId: 'xxxx1234'
};
dxPlugin.setCustomerPhoneNumber(params);
Track event:
trackEvent(params, success, failure)
parameter | type | description |
---|---|---|
params | Object | Options and value to be passed |
success (optional) | ( ) => void | Success callback - called after event has been tracked successfully |
failure (optional) | (err : Object) => void | Failure callback - called if event tracking fails |
params
name | type | default | description |
---|---|---|---|
BusinessProfileEncodedId (optional) | String | undefined | Id of the tracker for which customer id is to be set. If not passed, default customer id will be set for the default tracker instance |
TransactionId | String | undefined | If passed, the value will be used as event parameter |
CurrencyCode | String | undefined | If passed, the value will be used as event parameter |
TransactionValue | String | undefined | If passed, the value will be used as event parameter |
Quantity | String | undefined | If passed, the value will be used as event parameter |
CustomerId | String | undefined | If passed, the value will be used as event parameter |
CustomerMail | String | undefined | If passed, the value will be used as event parameter |
CustomerPhone | String | undefined | If passed, the value will be used as event parameter |
GoalId | String | undefined | If passed, the value will be used as event parameter |
Stage1 | String | undefined | If passed, the value will be used as event parameter |
Stage2 | String | undefined | If passed, the value will be used as event parameter |
Stage3 | String | undefined | If passed, the value will be used as event parameter |
Stage4 | String | undefined | If passed, the value will be used as event parameter |
Stage5 | String | undefined | If passed, the value will be used as event parameter |
Stage6 | String | undefined | If passed, the value will be used as event parameter |
Stage7 | String | undefined | If passed, the value will be used as event parameter |
Stage8 | String | undefined | If passed, the value will be used as event parameter |
Stage9 | String | undefined | If passed, the value will be used as event parameter |
Stage10 | String | undefined | If passed, the value will be used as event parameter |
XCart | String | undefined | If passed, the value will be used as event parameter |
Note: Setting values for CustomerId/CustomerMail/CustomerPhone will override the default value for the particular tracker for this particular event.
Example:
// If default customer properties (Id, Phone Number, Email) have been set for the tracker 'xxxx1234', they will also be part of the event
var params = {
BusinessProfileEncodedId: 'xxxx1234',
GoalId : '6AMDX4',
Quantity : '1'
};
dxPlugin.trackEvent(params);
// Since BusinessProfileEncodedId is not passed in params, default tracker instance will be used.
var params = {
GoalId : '6AMDX4',
Quantity : '1'
};
dxPlugin.trackEvent(params);
Track deep links:
trackClick(params, success, failure)
parameter | type | description |
---|---|---|
params | Object | Options and value to be passed |
success (optional) | ( ) => void | Success callback - called after deeplink click has been tracked successfully |
failure (optional) | (err : Object) => void | Failure callback - called if deeplink tracking fails |
params
name | type | default | description |
---|---|---|---|
Value | String | Default Customer Email / Phone Number to be set for a specific tracker instance | |
BusinessProfileEncodedId (optional) | String | undefined | Id of the tracker for which customer id is to be set. If not passed, default customer id will be set for the default tracker instance |
Uri | String | Full URI string of the deep link |
Example:
var params = {
BusinessProfileEncodedId: 'xxxx1234',
Uri: 'https://www.mytestdomain.com/test/123'
};
dxPlugin.trackClick(params);
Disable tracking:
disableTracking(success,failure)
parameter | type | description |
---|---|---|
success (optional) | ( ) => void | Success callback - called after successfully disabling tracking |
failure (optional) | (err : Object) => void | Failure callback - called if disable tracking fails |
Example:
dxPlugin.disableTracking();
Enable tracking:
enableTracking(success,failure)
parameter | type | description |
---|---|---|
success (optional) | ( ) => void | Success callback - called after successfully enabling tracking |
failure (optional) | (err : Object) => void | Failure callback - called if enable tracking fails |
Example:
dxPlugin.enableTracking();