[仅限PaaS]{class="badge informative" title="仅适用于云项目(Adobe管理的PaaS基础架构)和内部部署项目上的Adobe Commerce 。"}
创建自定义事件
您可以通过创建自己的店面活动来收集行业独特的数据,从而扩展事件平台。 创建和配置自定义事件时,会将其发送到Adobe Commerce事件收集器。
处理自定义事件
仅Adobe Experience Platform支持自定义事件。 自定义数据不会转发到Adobe Commerce功能板和量度跟踪器。
对于任何custom
事件,收集器:
- 添加以
identityMap
作为主标识的ECID
- 将
email
作为辅助标识identityMap
包含在 中,如果在事件中设置了personalEmail.address
- 在转发到Edge之前,将
xdm
对象中的完整事件打包
示例:
通过Adobe Commerce Events SDK发布的自定义事件:
mse.publish.custom({
commerce: {
saveForLaters: {
value: 1,
},
},
});
在Experience Platform Edge中:
{
xdm: {
identityMap: {
ECID: [
{
id: 'ecid1234',
primary: true
}
],
email: [
{
id: "runs@safari.ke",
primary: false
}
]
},
commerce: {
saveForLaters: {
value: 1
}
}
}
}
处理事件覆盖(自定义属性)
对于使用customContext
设置的任何事件集,收集器会覆盖或扩展custom context
中事件有效负载字段的字段。 覆盖的用例是当开发人员想要重用和扩展由已支持的事件中的页面其他部分设置的上下文时。
仅当转发到Experience Platform时,事件覆盖才适用。 它们不适用于Adobe Commerce和Sensei analytics事件。 Adobe Commerce事件收集器自述文件提供了其他信息。
productListItems
时,请使用SKU匹配产品。 此要求不适用于product-page-view
事件。使用情况
const mse = window.magentoStorefrontEvents;
mse.publish.productPageView(customCtx);
示例1
此示例在发布事件时添加自定义上下文。
magentoStorefrontEvents.publish.productPageView({
productListItems: [
{
productCategories: [
{
categoryID: "cat_15",
categoryName: "summer pants",
categoryPath: "pants/mens/summer",
},
],
},
],
});
示例2
此示例在发布事件之前添加自定义上下文。
const mse = window.magentoStorefrontEvents;
mse.context.setCustom({
productListItems: [
{
productCategories: [
{
categoryID: "cat_15",
categoryName: "summer pants",
categoryPath: "pants/mens/summer",
},
],
},
],
});
mse.publish.productPageView();
示例3
此示例在发布者中设置自定义上下文,并覆盖之前在Adobe客户端数据层中设置的自定义上下文。
在此示例中,pageView
事件在 字段中将具有 自定义页面名称2web.webPageDetails.name
。
const mse = window.magentoStorefrontEvents;
mse.context.setCustom({
web: {
webPageDetails: {
name: 'Custom Page Name 1'
},
},
});
mse.publish.pageView({
web: {
webPageDetails: {
name: 'Custom Page Name 2'
},
},
});
示例4
此示例将自定义上下文添加到具有多个产品的productListItems
事件。
const mse = window.magentoStorefrontEvents;
mse.context.setCustom({
productListItems: [
{
SKU: "24-WB01", //Match SKU to override correct product in event payload
productCategory: "Hand Bag", //Custom attribute added to event payload
name: "Strive Handbag (CustomName)" //Override existing attribute with custom value in event payload
},
{
SKU: "24-MB04",
productCategory: "Backpack Bag",
name: "Strive Backpack (CustomName)"
},
],
});
mse.publish.shoppingCartView();
基于Luma的商店:
基于Luma的存储以本机方式实施发布事件,因此您可以通过扩展customContext
来设置自定义数据。
例如:
mse.context.setCustom({
web: {
webPageDetails: {
name: 'Custom Page Name'
},
},
});