Advanced Custom Field Mapping

Sometimes you’d like to capture some data in a pre-chat or offline survey field and push that data to a specific field in SalesForce. Here’s how to make that happen.

1. Set up the field in your pre-chat survey or offline form so you can collect information from the visitor. In our example, we’re going to create a field to collect the visitor’s company information.

Navigate to the pre-chat or offline form page in your Olark dashboard. Add a custom field to your prechat survey or offline form. The custom field can be a single word, phrase, or even include punctuation like spacing between words.

Make note of the EXACT name of the field. This field is case-sensitive so uppercase and lowercase letters must match.

It is important to get the details exactly right with this field. Computers are pedantic or in other words fussy. This functionality will not work if you don’t use the exact name of the label you enter.

In our example, the field name is Company. Add Custom Pre-Chat Field GIF

2. In SalesForce, find or create the field you’d like to populate.

You’ll need to find the API name of the field.

Navigate to Setup > Objects & Fields > Object Manager and then choose Lead or Case, depending on which you’d like to use. Salesforce > setup >objects

Choose Fields & Relationships to see a list of fields. The API name of the field is listed in the FIELD NAME column.

Make note of the exact field name listed here. See above note re: computers are pedantic for more information on why this is important. Salesforce API Field Names

3. Create a script to push data from your pre-chat or offline field to your SalesForce field. This script does three things:

  • Listens for the visitor to enter information into your Olark form field (“Company” in the example below).

  • Names that data using a variable (CompanyName in the example) so it can be identified.

  • Passes the variable (and data) to the field in SalesForce.

In our example below, we identify the proper SalesForce field with the string salesforce_lead_value_Company. This is where you’ll use the API Field Name you identified in step 2 above. In our example this is Company.

If you’re sending data to a case, replace lead in this string with case.

olark("api.visitor.onChangeProvidedDetails", function (event) {
var CompanyName = event.newValue["Company"]; {
salesforce_lead_value_Company: CompanyName

4. Last step: Paste this script into your website’s code. If in doubt on where to place this code, you can add it right after your Olark installation code.

That’s it! Now, when Olark creates a lead or case in SalesForce, the data you captured in your pre-chat field will be populated in the SalesForce field you mapped to.

Important Notes

  • Olark will only send this information when creating a new case or lead in Salesforce. Existing cases and leads are never updated.
  • If you aren’t seeing your mapped data populate in SalesForce, triple check that you’ve entered the field names exactly (capitalization and punctuation included) from Olark & SalesForce into your script.
  • The script you create will work with both the pre-chat survey and offline forms as long as you have used the exact Olark form field names in your script. For example, if you have a pre-chat form field named Occupation and also an Offline Form field named Occupation, the script will send data from both forms “Occupation” field to the field you map “Occupation” to in SalesForce.
  • There are multiple options in Olark for custom field including Phone, Website, Text field, Textarea, and Radio. The radio option is only available for the pre-chat survey. Your selection in Olark must match the target Salesforce field’s type.

We’ll do our best to help with any questions you have. However, keep in mind that the API is intended to be self-serve for web developers, so we’re not able to write or debug your code. If you’re experiencing issues, please be sure to have your developer, designer, or webmaster review code you’ve written.

Was this article helpful?