subscribeRulesetItems
The subscribeRulesetItems command allows you to subscribe to propositions that are the result of satisfied rulesets. You can do this by specifying which surfaces and schemas to filter by, and providing a callback function.
Rulesets are evaluated each time a sendEvent command is sent. The callback function receives a result object with an array of propositions within it.
subscribeRulesetItems command is the only way to get propositions that come from rulesets, since they are not returned alongside sendEvent results. You must set up your subscription before calling sendEvent to ensure that propositions are captured.alloy("subscribeRulesetItems", {
surfaces: ["web://example.com/#welcome"],
schemas: ["https://ns.adobe.com/personalization/message/content-card"],
callback: (result, collectEvent) => {
const { propositions = [] } = result;
renderMyPropositions(propositions);
collectEvent("display", propositions);
},
});
The above code subscribes to the web://example.com/#welcome surface for content cards and uses the collectEvent convenience method to emit display events for all propositions.
Command options command-options
This command takes an options object with the following properties:
surfacesschemascallbackresult and collectEvent. See callback parameters for details.surfaces and schemas arrays.Callback parameters callback-parameters
The callback function receives the two parameters described in the table below when invoked.
resultpropositions array. These propositions are the direct result of satisfied rulesets. The result object is structured the same as the result object returned by sendEvent using a then clause.collectEventcollectEvent function collectevent-function
The collectEvent function is a convenience function that you can use to send Edge Network events to track interactions, displays and other events. It accepts the two parameters described in the table below.
display, interact, or dismiss.propositionsThe collectEvent function can be called independently outside of the callback. Calling this function is useful when tracking an interaction or dismissal at a later point, such as in response to a user action.
collectEvent("interact", propositions);
Subscribe to content cards using the Web SDK tag extension
The Web SDK tag extension equivalent to command responses is a rule that subscribes to the Subscribe ruleset items event. The event allows you to provide the desired schemas and surfaces.