search | Yext Hitchhikers Platform

Adding Answers JS to a page is a two step process.

  1. Initialize the library
  2. Add components.

Basic Initialization

The first step is to initalize the library. This is done using the ANSWERS.init command. This function accepts a set of configuration options.

At a minimum apiKey, experienceKey, businessId and experienceVersion must be specified. Here is an example.

ANSWERS.init({
  apiKey: "3517add824e992916861b76e456724d9",
  experienceKey: "answers-js-docs",
  businessId: "3215760",
  experienceVersion: "PRODUCTION",
  onReady: function() {
    // ADD COMPONENTS HERE
  },
});

The onReady property is used to add components. You can learn more about adding components in the Components section.

Additional Initialization Options

Learn more about additional initialization configuration in the verticalPages section.

Property Type Default Description
verticalKey
string
The vertical key to use for searches, passed to certain components. Required if a defaultInitialSearch is supplied.
limit
string
20
The number of results to display per page, defaults to 20. Maximum is 50.
defaultInitialSearch
string
A default search to use on page load when the user hasn’t provided a query. If set to “”, the SearchBar’s allowEmptySearch must be set to true.
Feedback