[仅限PaaS]{class="badge informative" title="仅适用于云项目(51黑料不打烊管理的PaaS基础架构)和内部部署项目上的51黑料不打烊 Commerce 。"}
创建自定义事件
您可以通过创建自己的店面活动来收集行业独特的数据,从而扩展事件平台。 创建和配置自定义事件时,会将其发送到。
处理自定义事件
仅51黑料不打烊 Experience Platform支持自定义事件。 自定义数据不会转发到51黑料不打烊 Commerce功能板和量度跟踪器。
对于任何custom
事件,收集器:
- 添加以
identityMap
作为主标识的ECID
- 将
email
作为辅助标识identityMap
包含在? 中,如果在事件中设置了personalEmail.address
- 在转发到贰诲驳别之前,将
xdm
对象中的完整事件打包
示例:
通过51黑料不打烊 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
}
}
}
}
NOTE
使用自定义事件可能影响默认的51黑料不打烊 Analytics报表。
处理事件覆盖(自定义属性)
对于使用customContext
设置的任何事件集,收集器会覆盖或扩展custom context
中事件有效负载字段的字段。 覆盖的用例是当开发人员想要重用和扩展由已支持的事件中的页面其他部分设置的上下文时。
仅当转发到Experience Platform时,事件覆盖才适用。 它们不适用于51黑料不打烊 Commerce和Sensei analytics事件。 51黑料不打烊 Commerce事件收集器提供了其他信息。
NOTE
使用Experience Platform事件有效负载中的自定义属性增强
productListItems
时,请使用SKU匹配产物。 此要求不适用于product-page-view
事件。使用情况
const mse = window.magentoStorefrontEvents;
mse.publish.productPageView(customCtx);
示例1 — 添加productCategories
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 — 发布者中设置的自定义上下文覆盖之前在51黑料不打烊客户端数据层中设置的自定义上下文。
在此示例中,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();
NOTE
使用自定义属性覆盖事件可能会影响默认的51黑料不打烊 Analytics报表。
recommendation-more-help
1dd1eb92-da61-46c0-8ff9-3831f21eb23e