In which two locations in the page Type definition can a developer pass in attributes?
Correct Answer: A,B
InSalesforce Marketing Cloud Personalization(formerly Interaction Studio), you can definepage types within theWeb SDKconfiguration (evergage.init(...)). Apage typehelps the system determine how to classify a given page and what data to capture. Developers often addcustom attributeswithin these page type definitions to enrich the captured context.
Below are the two primary methods (from the listed options) where a developer can pass in or define attributes:
1. isMatch (Option A)
* What It Is
* isMatch is a function used to determine if a particularpage typedefinition applies to the current page (based on URL, DOM elements, or other logic). It returns a boolean (true or false) to indicate whether the page matches this definition.
* Passing Attributes
* Inside the isMatch function, developers canaddormodifyattributes to enrich thecontext object. For example:
isMatch: function(context) {
// Check if page matches (e.g., URL pattern)
if (window.location.pathname.includes("/product/")) {
// Add custom attributes
context.addAttributes({
productCategory: "Shoes",
productType: "Sneakers"
});
return true;
}
return false;
}
* This ensures that whenever this page type's isMatch condition is true, certain attributes are set on the context.
* Salesforce Reference
* Salesforce Help:Web SDK Configuration GuideExplains how to set up page types, including using isMatch to define when a page type applies and how to add custom attributes.
2. onActionEvent (Option B)
* What It Is
* onActionEvent is a function within a page type definition thatfireswhenever anaction event (e.g., click event, impression event) is triggered. You can use this to capture more specific or dynamic data each time an action is recorded.
* Passing Attributes
* Within onActionEvent, you can also manipulate the event or context to setadditional attributes. For example:
onActionEvent: function(context, event) {
// For instance, if the user clicks a particular element:
if (event.action.name === "click") {
// Add or override attributes for this event
event.attributes = {
event.attributes,
clickedElementID: event.target.id
};
}
}
* This approach is particularly useful for capturing data specific touser interactions(clicks, hovers, form submissions, etc.).
* Salesforce Reference
* Salesforce Help:Handling Action Events in the Web SDKDescribes how onActionEvent can be used to modify event data, including adding custom attributes.