You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
Home > Features > How to send additional info about visitors to HappyFox Chat?
How to send additional info about visitors to HappyFox Chat?
print icon

With Custom fields you can pass additional data about customers from your website to HappyFox Chat via JavaScript SDK.

This feature is available in all plans.

For example, let us a registered user is visiting your website or initiating a chat. If you want to pass the subscription plan details of the user or the number of orders placed previously, to HappyFox Chat, the custom field enables that for you.

How to add custom fields?

Custom fields can be created in "Custom Fields" section under "Manage" tab of your HappyFox Chat Account.

Click on the "Add" button. Enter the name of the custom field.

Note: Text and Number are the two types of custom fields available. 

Choose any of the values and click on the "Save" button.

How to pass values to custom fields?

Custom fields can be passed from your website to HappyFox Chat using a JavaScript code snippet. 

Syntax:

HappyFoxChat.setCustomFields(<customFieldObject>, <callback>);
  • <customFieldObject> is a mandatory argument. A JSON object with the custom fields created in step 1.
  • <callback> is an optional argument.

Example:

HappyFoxChat.setCustomFields( { Plan :'free'} ) 

Here is a sample snippet of code to set some example custom fields (pastOrders and subscriptionPlan with values 30 and 'free' respectively): 

<script>
var HappyFoxChat;

window.HFCHAT_CONFIG.onload = function() {

  /**
   * Getting the reference of HappyFoxChat object
   */
  HappyFoxChat = this;

  /**
   * Custom fields
   */
  var customFields = {
    pastOrders: 3,
    Plan: 'free'
  };

  /**
   * Setting custom fields
   */
  HappyFoxChat.setCustomFields(customFields, function(error, result) {
    if (error) {
      console.error('Failed to set custom fields', error);
    } else {
      console.log('Successfully set custom fields', result);
    }
  });

};
</script> 

How to filter visitors using a custom field?

In "Visitors" tab, click on "By Filter" section.

Select "Add filter" option from the drop down list.

After setting filter name, set the necessary condition using the custom field. Visitors matching the conditions in the filter will be displayed.

Where will the Custom fields be displayed?

1. Agent Chat Interface

On clicking custom fields, the details passed will be displayed as shown below:

2. a) History > Chat transcripts

2.b) History > Offline messages

Feedback
2 out of 8 found this helpful

scroll to top icon