Wait! This article is part of our Developers section. Be sure to understand how each of the snippets works before customizing them for your site. We link to several helpful resources for learning, debugging and how we can help in our Developer API docs.

The pre-chat survey allows you to ask visitors for their name, email or phone number before starting a chat. You can enable and modify the survey in the Behavior and Text settings.

Enabling

Even if the pre-chat survey is enabled in your settings, you would need to enable the plugin using this code in order to use the API calls listed below. The call should be put directly under the /* custom configuration goes here (www.olark.com/documentation) */ line in your Olark install code.

olark.configure("features.prechat_survey", true);

To disable the pre-chat survey on a page, you can set it to false:

olark.configure("features.prechat_survey", false);

Modifying

You can always configure the pre-chat survey for all pages in your Behavior and Text settings. Should you wish to do this on a page-by-page basis, you can use our Javascript API to control which of the pre-chat survey fields are required before a chat begins. The options are:

  • "required" for a required field
  • "optional" for an optional field
  • "hidden" to hide a field

Insert code like this, into your Olark snippet:

// This line is required, even if already enabled in preferences
olark.configure("features.prechat_survey", true);

// Modification options
olark.configure('system.ask_for_name', 'required');
olark.configure('system.ask_for_email', 'optional');
olark.configure('system.ask_for_phone', 'hidden');

Advanced

If you are comfortable working with APIs, and already collect user data via your own login, you can send that information to Olark using our guide to Visitor Insights.