Usage
Parameters
Object mapping attribute names to functions that return the values to track.For each attribute:
- The key is the attribute name
- The value is a function that receives the current filter values and returns which values to track
Function to transform the rule contexts before sending them to Algolia.
Examples
Track specific brand values
Track all selected values
Conditional tracking
Transform rule contexts
Complex filtering logic
Use with Query Rules
In your Algolia dashboard, create query rules that target the contexts:- Context format:
ais-{attribute}-{value} - Example contexts:
ais-brand-Appleais-category-Electronicsais-brand-Samsung
Example rule
If filter isbrand:Apple, the context ais-brand-Apple is applied. You can then create a rule in your dashboard:
- Condition: Context is
ais-brand-Apple - Consequence: Boost hits with
badge: "iPhone"
Notes
- This is a renderless widget (no UI output).
- Rule contexts are automatically formatted as
ais-{attribute}-{value}. - Use with Algolia’s Query Rules feature for dynamic ranking and merchandising.
- The widget monitors refinements from other widgets.