Identify your users with PLuG
Once you have installed PLuG, all your users who interact with the widget are created as anonymous users in the DevRev app with a random name since there is no information about the user.
For users who are logged into your website, you can identify them in PLuG to enable them to view their conversation history and receive more personalized engagement.
To implement user identification, you need to generate a session token for each user who visits your website. This token is created using your application access token combined with customer information, and must be generated on your backend to keep the application token secure.
Generate an application access token
- In DevRev, go to Settings > Support > PLuG Tokens through the settings icon on the top-left corner.
- Under the Application access tokens panel, click New token and copy the token that’s displayed.
Ensure you copy your access token, as you cannot view it again.
Generate a session token
For security reasons, this API call must be made from the server side to prevent exposing your application access token (AAT).
Using the rev_info
method, you can generate and recognize a user within the DevRev system by providing relevant user details. This method enables you to convey information systematically, ensuring alignment between your DevRev CRM and the structured data model. For information regarding terminologies, click here.
Attributes for users
- While email uniqueness is subjected to organization preferences, it is not recommended to mark emails as non-unique.
Attributes for workspaces
Attributes for accounts
Ensure that you follow the specified format when populating phone numbers and domains in the request body.
Pass custom attributes
To create custom attributes, see Object customization.
You can pass the custom attributes that are created as shown below:
You can pass custom traits, as shown above, not only for users
but also for workspaces
and accounts
.
API status codes and troubleshooting
How resolution works
When you send object information to DevRev, the system automatically creates or finds existing contacts, accounts, and workspaces.
DevRev offers three ways to structure your customer’s data:
What happens when you send different combinations:
User reference:
- A user reference is mandatory, ensuring its constant presence.
- If a user with the provided reference doesn’t exist, the system automatically creates the user.
This approach ensures efficient management and integration of objects within the DevOrg.
Best practices
- Populate user traits like email and display name to make users identifiable and to prevent duplicate users across integrations.
- Maintain consistent unique identifiers across your system.
- Follow the specified formats for phone numbers and domains.
- Keep your application access token secure.
Pass the session token
While initializing the PLuG widget you pass the session token for DevRev to identify this user and thereby make the widget more customized for the user and their context.
Identify users without session token
You can also pass the identifiers in the plugSDK.init
option without generating the session token.
This frontend user identification, by its nature, is not secure as the data is transmitted through the client side. It is recommended to use the session token method to securely identify users.
This method is currently in beta and comes with the following limitations:
- Unverified users cannot be converted or merged into verified users.
- An external reference used by an unverified user cannot be reused for any other user.
You can add or update the data in user_traits
by using the updateIdentity
method on the PLuG SDK. Attached is a sample code snippet for the same.
Note that the updateIdentity
method cannot be used to update the user_ref
of the user. In order to change the identity of the user completely to a new one, you need to re-initialize PLuG. See the Changing the user identity section for more details.
Changing the user identity
As described in the above sections, to identify a user, you need to initialize the PLuG SDK with the relevant user information. PLuG can only be initialized once per page load.
In most cases, this works as expected—user identification typically happens after login or signup, which causes a page reload and clears any previous PLuG instance.
However, if your application needs to update the user identity without a full page refresh, you need to explicitly delete the existing PLuG instance before initializing it again with the new user information.
If you’re using the PLuG SDK for recording user sessions, calling the shutdown()
method will stop the ongoing session recording. Re-initializing with the init()
method will then start a new session recording. To avoid losing continuity, you can pass the details of the ongoing session recording when re-initializing PLuG.