How can I automatically set custom data?
If you are using Crisp on a website where users are authenticated, you may want to set their data.
Update one key/value
Using JS SDK
This method uses the Crisp JavaScript SDK, that you can call from your own front-end code.
// Feed this call with your own custom data.
$crisp.push(["set", "session:data", ["order_id", "3535353214"]]);
Using API
This method uses the Crisp REST API, that you can call from your own backend code. To make it easier, we have API wrappers available in several languages.
- session data: Update Conversation Metas
- contact data: Save People Data
You'll need to add your custom data in the "data" object in the request body:
{
"data": {
"plan_price": "95"
}
}
Update multiple key/values
Using JS SDK
// Feed this call with your own custom data.
$crisp.push(["set", "session:data", [
[
["order_id", "3535353214"],
["last_order_at", "04 January"],
["user_id", "XXXX-XXXX"]
]
]]);
Using API
- session data: Update Conversation Metas
- contact data: Save People Data
You'll need to add your custom data in the "data" object in the request body:
{
"data": {
"plan_price": "95",
"profile_link": "https://mylink.com"
}
}
Delete one key
Using JS SDK
// Set an empty value for this data
$crisp.push(["set", "session:data", ["order_id", ""]]);
Using API
- session data: Update Conversation Metas
- contact data: Save People Data
You'll need to submit an empty "data" object in the request body:
{
"data": {}
}
A practical use case: how do we use custom data at Crisp?
Here is an example of custom data we use at Crisp regarding our customers.
So you can better understand the information there, for each customer who gets in touch with us through chat, email, WhatsApp, etc. We have the following data available:
- user_id: Unique identifier that helps us to access a detailed view of the user profile.
- website_id: Unique identifier that helps us to access a detailed view of the website the user is part of.
- plan: The plan the user is using at the moment.
- plan_price: The price the customer is currently paying for our service.
- is_trialing: Whether the user is still under trial or not.
- Websites: How many inboxes the customer has created.
Thanks to these key data, we're able to personalize the customer experience, a lot. Note that these data are displayed in the conversation too as you can see in the example below.
Updated on: 03/03/2025
Thank you!