Custom Data Tutorial

Sending your data to the chat session

You can send application specific Webvisitor data to the Userlike chat session. This can either be basic information like name and email or any custom data that you think would be helpful for the chat operator seeing during the chat session. This could be all kind of data linked to the Webvisitor or session, even the current content of the shopping basket.

To pass on user information from your current web session to the current chat session, you need to pass an object to the "userlike.setData" function. To ensure that the Userlike client is already loaded, we recommend that you call "userlike.setData" from the "userlike.userlikeReady" callback.

Give your object the properties "user.name" and "user.email" to attach basic Webvisitor information. Furthermore, you can define the properties "user.additional01", "user.additional02" and "user.additional03" to send your custom additional Webvisitor values to the chat session make it available in the Chat Panel. You have to have the additional fields enabled for your Chat Widget to see this data.

More complex data like a shopping basket's content or the current web session's dump can be passed on to the chat session, too. The data needs to be JSON-serializeable and should be assigned as a javascript object to the "custom" property of your data object. If the data can be JSON-serialized it will be displayed as table view in the Chat Panel. As with the basic user information, the data will be attached to chat transcripts and available for later review.

Here is a sample of how to define a custom data object and then pass it to the chat session, using the "userlike.setData" function.

Updating a running chat session

If the Webvisitor data changes during the session or it becomes available only after a chat session is already started, you have to call "userlike.setData" with the updated data (again) and then call "userlike.userlikeUpdateAPI()" to trigger a chat session update with the newly provided information:

All data from the updated object will be pushed to the server again and become available in the running chat session. The Operator will be notified of the update by a "System Notification" bubble:

Access the custom data

Once the data has been set, the Operator can access it from the Chat Panel, using the "$info" macro.

Afterwards you can review your data in the Chat Transcript section: