connect-sdk-js v1.0.1
ConnectSDK
This package helps you integrate ConnectSDK into your application easily
Getting Started
Install with npm:
npm install connect-sdk-js
Install with yarn:
yarn add connect-sdk-js
Quick Start
Just add the following code:
import ConnectSDK from 'connect-sdk';
/* ... */
ConnectSDK.init({ app_key: "<your_app_key_comes_here>" }).then(() => {
ConnectSDK.trackEvent({ event_name: 'app_started' })
});
Initialize your app
Once installed, grab you app-key and include to your code:
import ConnectSDK from 'connect-sdk';
/* ... */
ConnectSDK.init(options); // Call this function when your app opens.
options
is an object that includes:
| Option | default | type | required | description |
| :-------- | :---------: | :------: | :------: | :----------------------------------------------------: |
| app_key
| undefined
| string
| Yes | Your application key provided by Connected Interactive |
Example
ConnectSDK.init({ app_key: "<your_app_key_comes_here>" }); // Add your app_key here
Add a Custom Event
To track custom events place the following code to your page, after our library from the previous step:
import ConnectSDK from 'connect-sdk';
// ...
ConnectSDK.trackEvent(options)
options
is an object that includes:
| Option | default | type | required | description |
| :------------ | :---------: | :------------------------: | :------: | :---------------------: |
| event_name
| undefined
| string
| Yes | Your custom event name |
| event_value
| undefined
| string | number | bolean
| No | Your custom event value |
Example
- To track custom events place the following code to your page, after our library from the previous step:
ConnectSDK.trackEvent({
event_name: 'my_custom_event'
});
- If you want to track events that have a value such as a monetary value, you could call the following code:
ConnectSDK.trackEvent({
event_name: 'my_custom_event',
event_value: 'my_value'
});