/ Coveo

Using a Coveo Search Page on a website

In the previous blog post, we discussed creating a Coveo search page. In this post we will explore how to integrate the Coveo Search page in a website.

How to Use the Coveo Search Page in Sitecore?

Prerequisites

  • Design a search hosted page on the Coveo platform.
  • Ensure the Coveo module is installed and configured.

Experience Editor

  1. Edit a Page: In the Experience Editor, you can use the out-of-the-box (OOB) component to create a data source that lists all the search pages created in Coveo.

  2. Add Component: Create or edit a page in the Experience Editor and add the Coveo Hosted Search Page Component.
    Add-a-Coveo-Hosted-Search-Page-to-Sitecore_

  3. Create Data Source: Create a data source for the component.
    Add-a-Coveo-Hosted-Search-Page-to-Sitecore_2

  4. Select Search Page: Once you open the data source, it should automatically show the list of pages available on the Coveo platform. Choose the desired search page and fill in the Search Hub for analytics purposes.
    Add-a-Coveo-Hosted-Search-Page-to-Sitecore_3

  5. Save and Reload: Save the data source and reload the page. The Coveo search interface should now be loaded.
    Add-a-Coveo-Hosted-Search-Page-to-Sitecore_4

Integrating the Coveo search interface in Sitecore is straightforward and requires no additional development.

How to Use the Coveo Search Page on a Non-Sitecore Website?

Prerequisites

  • Design a search hosted page on the Coveo platform.
  • Copy the ID of the search page.
  • Create Search token.
  • Create Page token.

Copy the Page ID

Copy the ID of the search page from the search pages section.

Add-a-Coveo-Hosted-Search-Page-to-any-website_1

API Token

Two API keys are needed: one to pull the search page design and another to perform the search.

One key cannot have both privileges, as pulling the page is an admin activity and searching is an end-user activity. Both privileges cannot be combined.

Add-a-Coveo-Hosted-Search-Page-to-any-website_2

Create a Search Token

  1. Create Search Token: This token is used for search and analytics push.

Add-a-Coveo-Hosted-Search-Page-to-any-website_3

  1. Set Privileges: Choose the preset Anonymous Search
    Analytics > Analytics data > Push.

Add-a-Coveo-Hosted-Search-Page-to-any-website_4

Search > Execute Queries > Allowed.

Add-a-Coveo-Hosted-Search-Page-to-any-website_5

  1. Save Token: Ensure you copy the values before closing the popup.
    Add-a-Coveo-Hosted-Search-Page-to-any-website_7

Create a Page Token

  1. Create Page Token: This token is used to pull the search pages.
    Add-a-Coveo-Hosted-Search-Page-to-any-website_3

  2. Set Privileges: Assign the necessary privileges as shown below.
    Add-a-Coveo-Hosted-Search-Page-to-any-website_6

  3. Save Token: Ensure you copy the values before closing the popup.
    Add-a-Coveo-Hosted-Search-Page-to-any-website_7

Now, you have both API keys created.

Add-a-Coveo-Hosted-Search-Page-to-any-website_8

Include the script

Use the following HTML and JavaScript code with the values generated in the previous step to load the Coveo search page on any website:

For further details, refer to:
https://source.coveo.com/2021/02/15/how-to-to-leverage-search-pages-api/
https://github.com/Coveo-Turbo/hosted-search-page

Credits:
Photo by Markus Winkler on Unsplash