Articles on: My Contacts

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.

Keys should always be lowercase. Special chars are not allowed except underscores and dashes.

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"]]);


Of course, you need to replace order_id and 3535353214 with your own key/values!

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"
   }
}


If you want to understand the difference between session data and contact data, please click here.

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", ""]]);


Want to know more about the JS SDK and $crisp interface? Read: How to use $crisp Javascript SDK?

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.



If you want to know more about custom data and why it is important, click here to access a dedicated article.

Updated on: 06/01/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!