JavaScript API - Custom User Attributes

screets Chat lets you create and track custom data attributes about your customers.

(!) Before starting

See how to create and manage your custom data attributes here.

Send "customer" data attributes with JavaScript

Creating attribute won't be populated for any of your customers yet, you'll need to send it to screets Chat via JavaScript. You can add your custom attributes (key/value pair) to your code snippet.

<script>
  window.screetsxi = {
    appid: "APP_ID",

    // Add your custom attributes here ("key": "value")
    custom_attrs: {
      "Plan ID": "1",
      "Plan Name": "Basic",
      "Last Order ID": "12345",
      "Last Order Details": "iPhone X, 256GB, Black",
      "Last Order At": 1150466020, // Date (unix timestamp)
      "Last Order Cost": 992.5, // Decimal
    },
  }
</script>

Send "chat" data attributes

When you send your custom attributes to screets Chat via JavaScript, they'll be added to the related chat.

Starting new chat with custom attributes

You can initiate a chat with custom data attributes by using the scxi('startChat') method.

scxi('startChat', { 
  msg: 'First message',
  
  // Add your custom attributes here ("key": "value")
  custom_attrs: {
    "Order ID": "12345",
    "Order Details": "iPhone 13, 256GB, Red",
    "Order At": 1150466020, // Date (unix timestamp)
    "Order Cost": 990.0, // Decimal
  },
}); 

Updating current chat with custom attributes

You can also update the current chat with custom data attributes by using the scxi('updateChat') method.

Last Updated: