If you’re familiar with our query rules feature, you know that it’s helpful to be able to test that your context rules are working end-to-end!
Here’s a quick and easy way to do that:
-
Set up a code sandbox that adds the search bar and sets context; you can fork this one as an example: Context + Query Rules - CodeSandbox. Replace the
[[REPLACE_ME]]
values with your own business id, api key, etc. -
Define your context in the constant on line 17. The sandbox has the following example:
const userData = {
name: "ava"
};
Update this value to be the context you’re expecting (to align with your query rule).
- Save the file and experiment with conducting searches, to make sure the experience reflects the query rule.
Here’s an example of us using this test on one of our demo accounts: Context + Query Rules - DTC - CodeSandbox. In this sandbox, we’re testing the following query rule:
{
"criteria": {
"contextContainsKey": "$.name"
},
"actions": [
{
"actionType": "ADD_FILTER",
"filter": {
"name": {
"$eq": "{{$.name}}"
}
},
"verticals": [
"products"
]
}
],
"name": "Filter By Product"
}
Let us know how this works for you!