Explore — Trending Questions

Show the questions trending across your site on a page with no article, such as a homepage or a section front.

Explore asks for related questions by default, and those need an article. Below we switch the workflow to trending questions, choose how many to show, and limit them to one brand.

You need a working Explore page first. See Explore — Quick Start.

Give useApi the API name as the first argument, and the request body as the second. Leave out product_id:

workflow.useApi("trending_questions", {
  rows: 5,
});

Call useApi before start(). The elements, useLink and start() stay as they are in the quick start.

The body takes the fields of the Trending Questions API:

FieldDefaultWhat it does
rows10How many questions to ask for.
_meta.site—Limits the questions to one site or brand, for a multi-brand app.

Limit the questions to one brand

In an app that holds more than one brand, set _meta.site to the brand of the page:

workflow.useApi("trending_questions", {
  rows: 5,
  _meta: { site: "markets" },
});

Render the value from your CMS, so each brand's homepage passes its own.

Change the response

The response puts the questions in related_questions, the same key as the Related Questions API. A useDataProcessor function from API Configuration works for both APIs without a change.

If it does not work

SymptomCause
No questions appearExplore is not enabled for this environment.
The request fails with product_id is requireduseApi has no API name, so the workflow asks for related questions.
Questions from another brand appearThe body has no _meta.site.

Next