One of the most common ways to integrate an Answers experience with your website is to add JS snippets to the page. In addition to guides for the Search Bar and Search Results integration, Answers now offers an in-platform Snippet Generator.
This convenient tool walks users through the process and automatically produces the JS code snippet needed to complete integration. Users can then easily copy and paste the premade snippet into their site without having to replace fields in the code snippet with variables from their account. This is currently only available for the static search bar, and not the overlay option.
Test out the new dimensions and filters in Hitchhikers and Playground Accounts. To turn on this beta feature (“Fall '21: Answers Snippet Generator (early access)”) in your Production account, you can fill out this form. Follow the steps below for how to use the Answers Snippet Generator.
- Navigate to your Yext account > Answers > Experiences > Experience Details page and select “Integrate Answers on Your Site”.
- Add Search Results: Select the site you want to integrate and the integration type you want to use.
If you select the JS Snippet approach, this will provide a code snippet to add the Answers experience to your search results page that you can use in the JS Snippet approach in the Creating a Search Results Page guide.
If you select the Subdomain approach, you will not need a code snippet to create your search results page.
- Add Search Bar: Enter the Search Results Page URL - the URL where you will be hosting your search results, or verify the URL indicated.
This will provide two code snippets to add the Answers search bar. The Search Bar JS Snippet at the top can be used in Step 1 of the Adding a Search Bar Guide to initialize the library. The second Search Bar Markup code snippet can be used in Step 2 of the Adding a Search Bar Guide to place the search bar.
The Answers Snippet Generator makes it much faster to get Answers live and integrated onto a site.