Fetching People Also Viewed content

Fetching People Also Viewed content

Display content similar to a given item based on visitors' behavior. Check out the Recommendations guide for a quick introduction.

The GraphQL API creates a corresponding GraphQL Type with a "people also viewed" algorithm for each content model in your environment. The plural Type name of the content model is prefixed with PeopleAlsoViewed_. For example Post generates a Type PeopleAlsoViewed_Posts.

query {
  PeopleAlsoViewed_Posts(
    id : "90276002-d628-4ba6-b3c8-f756c486b67b" ) {
    items {
        _id,
        title
    }
  }
}

Filtering recommended content items

To narrow down the recommended content items, use the same filters that are available when filtering collections.

In the following example, we query all Posts where premium is set to true.

query {
  PeopleAlsoViewed_Posts(
    id : "90276002-d628-4ba6-b3c8-f756c486b67b", where : { premium : true } ) {
    items {
        _id
    }
  }
}

Was this article helpful?

We’d love to learn from your feedback