1.0.1 • Published 6 years ago

@deltax-sdk/cordova-plugin-deltax-mobile-sdk v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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)
parametertypedescription
businessProfileEncodedIdsString Array of business profile encoded ids to initialise trackers
success( ) => voidSuccess callback - called after successful initialization (optional)
failure(err : Object) => voidFailure callback - called if initialization fails (optional)

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)
parametertypedescription
businessProfileEncodedIdStringArray of business profile encoded ids to initialise trackers
success( ) => voidSuccess callback - called after successfully setting default tracker (optional)
failure(err : Object) => voidFailure 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)
parametertypedescription
paramsObjectOptions and value to be passed
success( ) => voidSuccess callback - called after successfully setting customer id (optional)
failure(err : Object) => voidFailure callback - called if setting customer id fails (optional)

params

nametypedefaultdescription
ValueStringDefault Customer Id to be set for a specific tracker instance
BusinessProfileEncodedIdStringundefinedId 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)
parametertypedescription
paramsObjectOptions and value to be passed
success (optional)( ) => voidSuccess callback - called after successfully setting customer email/phone number
failure (optional)(err : Object) => voidFailure callback - called if setting customer email/phone number fails

params

nametypedefaultdescription
ValueStringDefault Customer Email / Phone Number to be set for a specific tracker instance
BusinessProfileEncodedId (optional)StringundefinedId 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)BooleanfalseBy 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)
parametertypedescription
paramsObjectOptions and value to be passed
success (optional)( ) => voidSuccess callback - called after event has been tracked successfully
failure (optional)(err : Object) => voidFailure callback - called if event tracking fails

params

nametypedefaultdescription
BusinessProfileEncodedId (optional)StringundefinedId 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
TransactionIdStringundefinedIf passed, the value will be used as event parameter
CurrencyCodeStringundefinedIf passed, the value will be used as event parameter
TransactionValueStringundefinedIf passed, the value will be used as event parameter
QuantityStringundefinedIf passed, the value will be used as event parameter
CustomerIdStringundefinedIf passed, the value will be used as event parameter
CustomerMailStringundefinedIf passed, the value will be used as event parameter
CustomerPhoneStringundefinedIf passed, the value will be used as event parameter
GoalIdStringundefinedIf passed, the value will be used as event parameter
Stage1StringundefinedIf passed, the value will be used as event parameter
Stage2StringundefinedIf passed, the value will be used as event parameter
Stage3StringundefinedIf passed, the value will be used as event parameter
Stage4StringundefinedIf passed, the value will be used as event parameter
Stage5StringundefinedIf passed, the value will be used as event parameter
Stage6StringundefinedIf passed, the value will be used as event parameter
Stage7StringundefinedIf passed, the value will be used as event parameter
Stage8StringundefinedIf passed, the value will be used as event parameter
Stage9StringundefinedIf passed, the value will be used as event parameter
Stage10StringundefinedIf passed, the value will be used as event parameter
XCartStringundefinedIf 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)
parametertypedescription
paramsObjectOptions and value to be passed
success (optional)( ) => voidSuccess callback - called after deeplink click has been tracked successfully
failure (optional)(err : Object) => voidFailure callback - called if deeplink tracking fails

params

nametypedefaultdescription
ValueStringDefault Customer Email / Phone Number to be set for a specific tracker instance
BusinessProfileEncodedId (optional)StringundefinedId 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
UriStringFull 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)
parametertypedescription
success (optional)( ) => voidSuccess callback - called after successfully disabling tracking
failure (optional)(err : Object) => voidFailure callback - called if disable tracking fails

Example:

dxPlugin.disableTracking();

Enable tracking:

enableTracking(success,failure)
parametertypedescription
success (optional)( ) => voidSuccess callback - called after successfully enabling tracking
failure (optional)(err : Object) => voidFailure callback - called if enable tracking fails

Example:

dxPlugin.enableTracking();