# DevRev

**Prerequisite**: You should have a DevRev user identification setup on your site. For more information read: <https://docs.devrev.ai/plug/users-identify>

### 1. Create a field in DevRev to hold Zipy session url.

In DevRev, go to **Settings > Object customization > Contact** through the settings icon on the top-left corner.

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FGlcMg9Wf3reZLLBJrk2y%2FScreenshot%202024-03-12%20at%2011.46.19%E2%80%AFAM.png?alt=media&#x26;token=4d66885a-af37-4266-8802-d39b56b4114a" alt=""><figcaption></figcaption></figure>

Enter the field name as **Zipy Session Url**. Select field type as **Text**. Then click on **Save to draft.**

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FAndUlTMqdTxechJAPaYP%2FScreenshot%202024-03-12%20at%2011.56.29%E2%80%AFAM.png?alt=media&#x26;token=e625f319-d782-4e5a-a0e9-3e9bc73a6bde" alt=""><figcaption></figcaption></figure>

### 2. Include Zipy session url in data body while calling the identify user API

Add Zipy session url in the data body while calling the identify user API. In the 'custom\_fields' object inside 'user\_traits' add a key-value pair with key as '**tnt\_\_zipy\_session\_url**' and its value as zipy session url.

```javascript
<script>
const getCurrentZipySessionURL = async () => {
  return await new Promise(function(resolve, reject) {
      let i = 0;
      const _interval = setInterval(() => {
          let zipySessionUrl = (window)?.zipy?.getCurrentSessionURL();
          
          if(zipySessionUrl){
              resolve(zipySessionUrl);
              clearInterval(_interval);
          }
          else{
              i++;
              if(i >= 4){
                reject("Some problem occurred while loading zipy.");
                clearInterval(_interval);
              }
          }
      },1500);
  });
}

getCurrentZipySessionURL()
.then(zipySessionUrl => {
// Call your identify API here with modified data body containing zipy session url.

/* Example data body with zipy session url */
/*   
    {
         "rev_info": {
             "user_traits": {
                "email": "<end_user_email>",
                "custom_fields": {
                    "tnt__zipy_session_url": zipySessionUrl
                }
             }
         }
    }
*/

})
.catch((e) => {
    console.log(e);
});
</script>
```

### 3. Pass the session token generated to the init method

You can get **<*****your\_unique\_app\_id>*** in **Settings > Support > PLuG settings** through the settings icon on the top-left corner.

You will get ***\<SESSION\_TOKEN>*** in the response after calling the identify user api.

```javascript
window.plugSDK.init({
  app_id: '<your_unique_app_id>',
  session_token: '<SESSION_TOKEN>' /* You will get this session 
  token in the response of identify user api.*/
});
```

After performing the above steps you will be able to see Zipy session url corresponding to a user in DevRev.

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FuqhkMhlUSvVBwaWGLgnV%2Fimage.png?alt=media&#x26;token=06cb1384-7bef-4c0a-b3aa-5bbd7b44e55f" alt=""><figcaption></figcaption></figure>
