How to collect user's session data and auto login within your Live Chat

Do you want to recognize the user when they signup or sign in in your platform? It's an easy thing to do with Customerly

Luca Micheli
Written by Luca MicheliLast update 1 year ago

Do you have a web session on your website? Do you want to auto-login people even in your Live Chat? 

This way when your user will log into your platform and he wants to open a new ticket, Customerly will recognize him immediately. 

Benefits for you are multiple:

  1. Users will have less friction by opening a ticket

  2. You will have all the ticket's track records for the same user

  3. You can collect useful information about your customers to speed up the customer service

If you have integrated the basic snippet, this is how you can add properties. In the following example, we added the user id = 4, the name and email and three properties.

<script>     
!function(){var e=window,i=document,t="customerly",n="queue",o="load",r="settings",u=e[t]=e[t]||[];if(u.t){return void u.i("[customerly] SDK already initialized. Snippet included twice.")}u.t=!0;u.loaded=!1;u.o=["event","attribute","update","show","hide","open","close"];u[n]=[];u.i=function(t){e.console&&!u.debug&&console.error&&console.error(t)};u.u=function(e){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(e),u[n].push(t),u}};u[o]=function(t){u[r]=t||{};if(u.loaded){return void u.i("[customerly] SDK already loaded. Use customerly.update to change settings.")}u.loaded=!0;var e=i.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://messenger.customerly.io/launcher.js";var n=i.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};u.o.forEach(function(t){u[t]=u.u(t)})}();         
  
customerly.load({   
app_id: "00c4edo7",

user_id: 4, // Optional
       name: "Sarah",
       email: "sara@company.com"


//Properties can be added here as you wish
       attributes: {
           subscription_type: "2",
           created_at: 1384902000, // Signup date as a Unix timestamp
           license_expire_at: 1603490400


           //Add another property here that you might need to track
           //The format should be
           //property_name: property_value
       }


 });
</script> 
<!-- End of Customerly Live Chat Snippet Code -->

The attributes array is customizable with an infinite number of custom properties. 

Do you want to track your user plan and trial status? It's easy, just add another line of code like this:

  attributes: {
            subscription_type: "2",
            created_at: 1384902000, // Signup date as a Unix timestamp
            license_expire_at: 1603490400,
            plan: "pro",
            status: "trial"
        }

If the user sign in again and you change the status from trial to paying, we will update instantly the data point on our side. This will help you track your user status and also this will help you creating funnels that will be triggered automatically based on your user status. 

The attributes can be of different types:

  • String (eg. Pro)

  • Number (eg. 1,2,10000)

  • Date (only timestamp in seconds will be accepted)

  • Boolean (true or false, 0 or 1)

We try to recognize the property type automatically, but in some cases, you might want to customize the property type in your settings.

Did this answer your question?