Default Initial Search on Universal Search

The typical user journey is that a user enters a search into a search bar and then lands on the search results page with exactly the answer they’re looking for. However, sometimes users land on the search results page before a query has been run (or perhaps the brand didn’t have the bandwidth to build the preferred searchbar so they only included a link to the search experience from their homepage). When this happens, they see an empty page!

Now, you can pin results to an empty query to automatically showcase specific results when this happens:

How to apply a default initial search:

  1. In your index.json, update the SearchBar component in componentSettings with "allowEmptySearch": true
  2. In your index.json, add pageSettings to include the default initial search. This should go outside of componentSettings (same place where it is in your verticals).
  "pageSettings": {
    "search": {
      "defaultInitialSearch": "" // Enter a default search term, should be your pinned query
    }
  },
  1. Update your search configuration to include a pinned result. You can read more about how pinned results work here. Here’s a sample:
   {
      "criteria": {
        "searchTermMatchesRegex": "^$",
        "searchTypes": "UNIVERSAL"
      },
      "actions": [
        {
          "actionType": "RETURN_PINNED_RESULT",
          "verticals": [
            {
              "savedFilterId": "[[ENTER FILTER ID]]",
              "verticalKey": "videos"
            },
            {
              "savedFilterId": "[[ENTER FILTER ID]]",
              "verticalKey": "states"
            }
          ]
        }
      ],
      "name": "Default Search"
    }
  1. Confirm the search works! Note that these default initial searches count as a search (and therefore towards your search capacity).

:spiral_calendar: This feature is available in Early Access. Here’s how to use the Early Access branches of the Theme and SDK!

3 Likes

Love this! I’ve had a ton of clients ask for this feature and be concerned for users who land on an empty search results page. This is going to be great! Thanks, Alyssa!

This is awesome.

Is there a way to enhance this further to dynamically render the results based on the page they have just navigated from? For example, this solution could be implemented on a 404 page, meaning if a user lands on a 404 page, the user experience of the 404 page content can be enhanced via Answers displaying some content along side the 404 message - however, if the content rendered could be based on the referring URL that would be even better. Just a thought

@ahubbard sorry for bringing this back but this is great! I haven’t used this before, but brought it up to my client since they don’t the default universal search behavior to be an empty search page. They’re concerned that the default search will affect their analytics/search query count, so I just wanted to confirm that the default search won’t affect these? Thanks so much!

Hey @Chris_Xi,

Adding a default initial search will affect analytics and search count. In order to surface any results within Answers, a search has to be initiated to trigger a response from the API with the desired search results.

That being said, it is usually very uncommon to end up on the Universal search page without having typed a query. The main exception would be if the client has not implemented a search bar and is instead linking people directly to the Answers experience to initiate a search.

Best,
DJ

Super helpful context, thanks so much DJ!

Do you need to be on a specific SDK or Theme to take advantage of this feature?

Hey Khari,

You’ll need to be on Theme 1.20/SDK 1.8 or above to use this feature!

Best,
DJ