By leveraging the capabilities of the Doofinder Script, you can effectively manage and personalize the visibility of your product catalog for different user groups. This approach involves three key steps: indexing an attribute for product visibility, implementing dynamic variables for user group identification, and modifying the Doofinder Script to apply these variables.
You can dynamically filter/exclude search results directly with the following additional Script.
Filter
(function(w, k) {w[k] = window[k] || function () { (window[k].q = window[k].q || []).push(arguments) }})(window, "doofinderApp")
doofinderApp("init", "layer", {
params:{
"":{
filter: {
attribute: ["value"]
}
}
}
});
Exclude
You could also exclude a specific attribute/value using the following parameter:
(function(w, k) {w[k] = window[k] || function () { (window[k].q = window[k].q || []).push(arguments) }})(window, "doofinderApp")
doofinderApp("init", "layer", {
params:{
"":{
exclude: {
attribute: ["value"]
}
}
}
});
Here, for example, we will filter the search results, so only the category "visible" will return results:
(function(w, k) {w[k] = window[k] || function () { (window[k].q = window[k].q || []).push(arguments) }})(window, "doofinderApp")
doofinderApp("init", "layer", {
params:{
"":{
filter: {
category: ["visible"]
}
}
}
});
Please, note that this script is additional and doesn't replace the original single script responsible to shows the Doofinder layer.
Please, find below a complete example of this integration:
<script src="https://eu1-config.doofinder.com/2.x/a93b2f56x-8c4d-3a7e-f12b-x6d9eaa74b3c9.js" async></script>
<script type="text/javascript">
(function(w, k) {w[k] = window[k] || function () { (window[k].q = window[k].q || []).push(arguments) }})(window, "doofinderApp")
doofinderApp("init", "layer", {
params:{
"":{
filter: {
category: ["visible"]
}
}
}
});
</script>
Different user groups
If you have different user groups, with specific rules to access the product catalog, follow these steps:
- Index an attribute for product visibility
- "available_for_groups": "A/B/C" // this product is available for groups A, B, and C
- "available_for_groups": "A/C" // this product is available for groups A and C
- Implement dynamic variables for user group identification
- Modify the Doofinder Script
- the attribute indexing the values for which the product is available is named "available_for_groups".
- the variable identifying the user group from your HTML code is named "dfGroupFilter".
In your product data feed, you will need to index an attribute, indicating the visibility to your user groups, for each product. Let's take the following case, for which we have three different user groups: A, B, and C.
We index the following attribute:
Next up, it's time to integrate dynamic variables into your HTML code to distinguish between user groups. Align these variables with the "available_for_groups" attribute in your feed, ensuring seamless coordination between the two. It is required that both the values of this dynamic variable and the values of the "available_for_groups" attribute in your feed share the same values.
For instance, in your product data feed, index the attribute as follows: A
In your HTML code, create the corresponding variable: let dfGroupFilter = "A"
In our example, dfGroupFilter can take the value “A”, “B” or “C”
In our example:
Here is what the Doofinder Script would look like:
(function(w, k) {w[k] = window[k] || function () { (window[k].q = window[k].q || []).push(arguments) }})(window, "doofinderApp")
doofinderApp("init", "layer", {
params:{
"":{
filter: {
available_for_groups: [dfGroupFilter]
}
}
}
});
Conclusion
This method ensures that only the appropriate products are shown to the corresponding user groups, enhancing user experience and maintaining the integrity of your product visibility rules. By following these steps, you can create a more tailored and secure shopping experience environment for your users.