Using Contexts in your configuration
In many dialog, you can define Contexts (i.e.: for Facets, Rules, etc.). These contexts always function in a similar manner which we describe in this article.
Why using Contexts?
If you want to configure something generally, you don’t need to use any contexts. Contexts are defining a reduced scope in which your configuration should apply.
For example, if you want a facet to appear only in one category, or a rule to only affect one specific search query, then you need a context to limit the scope of the configuration.
Context or Segmentations?
You can define segmentations in the view Merchandising Segmentation.
These segmentation can be used in Widget Use-Cases as well as in Context.
So for many cases, you don’t need a segmentation to have a context, but in advanced cases, you might need it. Then define first your segmentation and then use it in your context.
How does a context applies in my configuration?
So if you want to overwrite a general behavior to be different in a specific case, you will need to do two configuration, one general (without any context) and one specific (with the context).
In the vast majority of the case, the system will apply the most specific applicable context available.
So in the general case, only the general configuration applies. But in the specific context, both the general and the specific context applies, so the specific configuration will overwrite the general configuration (for all the parameters which are defined in the specific case, the general parameters which are not overwritten in the specific context case will still apply).
What makes a configuration context more specific than another?
Let’s imagine you do 3 configurations, one general, one with 1 context (for example a filter) and one with 2 defined contexts (for example, a language and a filter).
The one with 2 contexts will be considered as more specific than the two others.
Two configurations having each one context will be considered equal and will be applied in a non-deterministic order, so you want to avoid such case as much as possible (there is one exception, when you defined a filter on a category, then the system will check what is the most detailed level of category and will apply this one, so the category A>>B>>C is more specific than the category A>>B).
What are the different types of contexts?
The system offers the following contexts:
Search query (the exact keyword(s) the user is searching on your web-site)
Context Items (for PDP recos: what is the current Product Page and for basket recos: what are the current products in his basket) you can refine to a sub-set of products or categories
Variant: an a/b test variant name (all small caps and no punctuation please, so only small letters without numbers)
Context parameters: if you know that some special parameters are passed with the request you can do a logic to only apply something if these parameters are set with these values
Filters: for category/brand pages with product listing: what are the current filters and selected facets
Widget : the name of the current widget
Language: a specific language
Segmentation: a segmentation defined in the Segmentation Menu
Script Condition (advanced): A condition defined in a Template Resource (or typed directly as a moustache template)