> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.co-din.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How can I automatically set user segments?

Articles on: [My Contacts](/en/category/my-contacts-4e84h7/)

If you are using Crisp on a website where users are authenticated, you may want to set their segment.  
  
This method uses the Crisp JavaScript API, that you can call from your own code. Thanks to [segment](https://crisp.chat/en/crm/customer-segmentation/), you'll be able to group users based on their interactions with your website or your software.  
  
It will be then super useful when targeting them later on to send them marketing campaign.  
  
Here's how you would proceed to set the visitor's data:  
  

``` // Feed this call with your own internal segment. $crisp.push(["set", "session:segments", [["registered_users", "lead"]]])```

  
  
Of course, this example is using two segments. It's possible to use only one. Also you need to replace registered_users and lead with your own segments!  
  
Want to know more about the $crisp interface? Read: [How to use $crisp Javascript SDK?](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/dollar-crisp/)

Updated on: 13/06/2022