Skip to main content

User groups in Nosto Search

How to use group visibility and other group-specific values

Florian Niedermayr avatar
Written by Florian Niedermayr
Updated over 2 weeks ago

General information

Nosto Search supports the implementation and use of user group-specific data, allowing you to tailor product information to different user groups (e.g. "B2B"/"B2C", "LoggedIn"/"Guest"). This capability is particularly useful for customizing product visibility, availability, and pricing based on the active user group.

Nosto currently supports group-specific values for the following fields:

  • Visibility

  • Availability

  • Price

  • List Price

  • Price Currency Code

For detailed, step-by-step instructions on how to implement user group-specific information in Nosto Search, please refer to the next chapter.

Implementation guide

The examples in the following sections use fictional groups “B2B” and “B2C”, representing business- and private customers, which often receive different prices or other information.

Steps for implementing group visibility of products

  • Send product data to Nosto containing a custom field that contains all groups this product should be visible to as a JSON array.

  • Create a JSON array data extractor for this field.

  • Mark the extracted field as indexed. For the configuration in the screenshot, the field name would be extra.customFields.variant-listing-config.

  • Include a filter in each search request using the extracted field and the current user’s group, as it was provided in the product data.

Using the example described above, a custom field value for products visible to both groups would look like [“B2B”, “B2C”]. The custom field value for a product visible only to business customers would look like [“B2B”].

The filter value in such an example would be either B2B or B2C.

Steps for implementing group-specific values

  • When sending product data to Nosto, include one variation for each product containing the variation-specific data (e.g. price). The variantId must be the group name as used for visibility.

  • In all search requests, set the variationId parameter to the current user’s group value, as it was used in the product data.

In the common example described above, variation IDs would be B2B and B2C.

The final GraphQL request might look like this:

query {
search(
query: "shirt"
products: {
variationId: "B2C"
filter: [
{
field: "extra.customFields.variant-listing-config",
value: "B2C"
}
]
}
) {
query
products {
hits {
productId
url
name
imageUrl
price
}
}
}
}

Alternative steps for visibility when both visibility and group-specific values are needed

Visibility of a product for a group could also be controlled by setting the availability property of a group’s variation to Invisible for all groups that should not be able to see the product. This is easy if variations are already necessary for group prices.

This works because variation values transparently replace the top-level product’s values when selecting a variation, including availability.

The final GraphQL request might look like this:

query {
search(
query: "shirt"
products: {
variationId: "B2C"
}
) {
query
products {
hits {
productId
url
name
imageUrl
price
}
}
}
}

Workaround for providing additional group-specific data

Variations don’t support custom fields, so providing additional information (e.g. group-specific badges) specific to a group is not possible using variations.

As a workaround, add a custom field to the top-level product that contains a JSON object that has group names (matching variation IDs) as properties, and an object of group-specific data as values.

Example: Each group has different tax information that needs to be visualized in the product card. The custom field JSON value to transmit that information could look like this:

{
“B2B”: {
“taxRate”: 0
},
“B2C”: {
“taxRate”: 20
}
}
Did this answer your question?