Pre-selecting Advisor Questions

Learn how to use the function crobox.setFinderState to control the state of the advisor via our JavaScript API. You can pre-select answers for specific questions, and control question page navigation.

Overview

The crobox.setFinderState method allows you to control various aspects of the Advisor experience, such as pre-selecting answers for specific questions and managing page navigation during the interaction.

This method should be used in addition to the pageview event. It is not part of the pageview event itself.

Key Features

  • Set pre-selected answers for questions

  • Control page navigation, either by skipping certain pages or showing a page with pre-selected answers.

Implementation

To implement the crobox.setFinderState method, you will need to include it in your crobox.push() call, which initializes the interaction with the Crobox API.

Example Snippet

Below is an example of how to set the Advisor state with the crobox.setFinderState method. Note that the references below (such as {shoe-finder} {page-gender}, {gender}, {men} and {page-category},{category} and {trail} ) are used as examples for the finder key, page key, question key, and answer keys. You should replace these placeholders with the appropriate keys specific to your Advisor.

window.crobox = window.crobox || [];

crobox.push(function(crobox) {

// Set answers for the Finder (e.g., skip a question page for a pre-selected answer or show the user a pre-filled answer within the question page)
  crobox.setFinderState('shoe-finder', {
    'page-gender': '1',  // Page is submitted (‘1’), otherwise omit the element
    'gender': 'men',     // Question ‘gender’ is answered with: 'men' (other option: 'women')
    'category': 'trail'  // Question ‘category’ is answered with: 'trail' (other options: 'road', 'hiking')
  });
});

Explanation

crobox.setFinderState(): This function sets the state for the Finder based on the values you define. In this example:

  • Gender question: The page key page-gender is submitted, which corresponds to the page being skipped for the user within their finder interaction. The question key gender is set to 'men', which corresponds to the answer 'men' in the Finder.

  • Category question: The page key page-category is not included in the push, which corresponds to the page being shown to the user in their finder interaction with the answer pre-filled. The key category is set to 'trail', indicating the user is interested in trail shoes.

You can control whether the page is shown with pre-selected answers or skipped entirely. The setFinderState method allows you to navigate directly to a specific question, the ‘page-gender':’1’ example is used above.

Last updated

Was this helpful?