By default, the chat widget requires customers to enter their email to start a chat. This works if your clients are on your website and you don't know their name and email.
However if your users are already logged into your product then you can auto populate their name and email. This is is also helpful to track user activities, even if the customer doesn't start a conversation.
To do this, add the following script to your project:
<script>
window.NeetoWidgetUserIdentity = {
user_identifier: "USER_ID_HERE",
name: "USER_NAME_HERE",
email: "USER_EMAIL_HERE",
started_at: "YYYY-MM-DD",
}
</script>
This can also be used at run-time in SPA's like React, Vue, etc.
Video
Automatically prefill values for custom fields:
Above, we saw how to provide the data for pre-chat questions. We can use the same method to provide the data for custom fields available at Settings > General Settings > Fields.
Each Field has a unique identifier (key), and you can add the value for each field by including the key in the NeetoWidgetUserIdentity object. This key can be copied from the Fields table.
Here's an example with multiple custom fields:
<script>
window.NeetoWidgetUserIdentity = {
user_identifier: "USER_ID_HERE",
name: "USER_NAME_HERE",
email: "USER_EMAIL_HERE",
started_at: "YYYY-MM-DD",
age: "USER_AGE",
gender: "USER_GENDER",
country: "USER_COUNTRY",
// Add other custom fields here
}
</script>