1. In order to integrate the Cordova Hybrid Plugin, developers need to have the AppKey and WorkspaceId generated in the previous steps. While initializing the Plugin in the app, the AppKey and WorkspaceId need to be passed.

  2. To integrate Datagran Cordova Plugin, follow the below instructions. The latest plugin version is "1.0.3" .

    **Instructions to add the Cordova hybrid plugin from Gitlab:**
    1. Open the terminal and set your project path.
    2. Run the below command to add the Cordova android plugin.
    cordova plugin add <https://gitlab.com/datagran/datagran-cordova-plugin.git#{latest_version}>
    
    **Instructions to update the Cordova hybrid plugin:**
    1. Open the terminal and set your project path.
    2. Run the below commands.
    cordova plugin rm datagran-cordova-plugin
    cordova plugin add <https://gitlab.com/datagran/datagran-cordova-plugin.git#{latest_version}>
    
  3. Follow the below steps to setup the iOS platform.

  4. Add the following lines to your code to be able to initialize tracking with your own Datagran AppKey and WorkspaceId. The Cordova plugin will initialize the SDK in the app and pass the DatagranAppKey, DatagranWorkspaceId along with a couple of other parameters such as context, addGeo, DatagranBatchValue and DatagranWaitResponse. During the initialize method call, the user’s session "dg_user_id" will be automatically created inside the SDK.

    document.addEventListener('deviceready', function() {
    
       cordova.plugins.datagran.initSdk({
          datagranAppKey: "5e********************19", // your Datagran Android/iOS AppKey
          datagranWorkspaceId: "5e********************65", // your Datagran Android/iOS WorkspaceID
          datagranBatchValue: 10,
          datagranWaitResponse: 60
        },
          (result) => {
            console.log(result);
          },
          (error) => {
            console.error(error);
          }
        );
      
    }, false);
    

Now the integration of the datagran Cordova plugin with the application is complete.