-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommerce-handler.js
More file actions
66 lines (62 loc) · 2.29 KB
/
commerce-handler.js
File metadata and controls
66 lines (62 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function CommerceHandler(common) {
this.common = common || {};
}
CommerceHandler.prototype.logCommerceEvent = function () {
/*
Sample ecommerce event schema:
{
CurrencyCode: 'USD',
DeviceId:'a80eea1c-57f5-4f84-815e-06fe971b6ef2', // MP generated
EventAttributes: { key1: 'value1', key2: 'value2' },
EventType: 16,
EventCategory: 10, // (This is an add product to cart event, see below for additional ecommerce EventCategories)
EventName: "eCommerce - AddToCart",
MPID: "8278431810143183490",
ProductAction: {
Affiliation: 'aff1',
CouponCode: 'coupon',
ProductActionType: 7,
ProductList: [
{
Attributes: { prodKey1: 'prodValue1', prodKey2: 'prodValue2' },
Brand: 'Apple',
Category: 'phones',
CouponCode: 'coupon1',
Name: 'iPhone',
Price: '600',
Quantity: 2,
Sku: "SKU123",
TotalAmount: 1200,
Variant: '64GB'
}
],
TransactionId: "tid1",
ShippingAmount: 10,
TaxAmount: 5,
TotalAmount: 1215,
},
UserAttributes: { userKey1: 'userValue1', userKey2: 'userValue2' }
UserIdentities: [
{
Identity: 'test@gmail.com', Type: 7
}
]
}
If your SDK has specific ways to log different eCommerce events, see below for
mParticle's additional ecommerce EventCategory types:
10: ProductAddToCart, (as shown above)
11: ProductRemoveFromCart,
12: ProductCheckout,
13: ProductCheckoutOption,
14: ProductClick,
15: ProductViewDetail,
16: ProductPurchase,
17: ProductRefund,
18: PromotionView,
19: PromotionClick,
20: ProductAddToWishlist,
21: ProductRemoveFromWishlist,
22: ProductImpression
*/
};
module.exports = CommerceHandler;