カートインタラクション
カートインタラクションでは、顧客がオンラインショッピングカートの内容を変更できます。
カートインタラクションには次の 2 つの形式があります。
- 単一品目: 顧客のカート内の個々の品目を変更します。
- 複数品目: 顧客のカートに対して一括操作を行います。
単一品目
次のインタラクション名は、個々の品目に影響するカートインタラクションで使用されます。
| インタラクション名 | 値 |
|---|---|
| SalesforceInteractions.CartInteractionName.AddToCart | Add To Cart (カートに追加) |
| SalesforceInteractions.CartInteractionName.RemoveFromCart | Remove From Cart (カートから削除) |
1{
2 interaction: {
3 name: "Add To Cart",
4 lineItem: {
5 catalogObjectType: "Product",
6 catalogObjectId: "product-1",
7 quantity: 1,
8 price: 9.99,
9 currency: "USD",
10 attributes: {
11 giftWrapping: true
12 }
13 }
14 }
15}単一品目カートインタラクションの項目。
| 項目名 | 項目の型 | 説明 |
|---|---|---|
| lineItem | 品目データ | 必須。1 つの品目データ値。 |
| name | string | 必須。イベント名。 |
複数品目
カート内のすべての品目に影響するカートインタラクションで使用されるインタラクション名。
| インタラクション名 | 値 |
|---|---|
| SalesforceInteractions.CartInteractionName.ReplaceCart | Replace Cart (カートを置き換え) |
1{
2 interaction: {
3 name: "Replace Cart",
4 lineItems: [{
5 catalogObjectType: "Product",
6 catalogObjectId: "product-1",
7 quantity: 1,
8 price: 9.99,
9 currency: "USD",
10 attributes: {
11 giftWrapping: true
12 }
13 }, {
14 catalogObjectType: "Product",
15 catalogObjectId: "product-2",
16 quantity: 3,
17 price: 20,
18 currency: "USD",
19 attributes: {
20 giftWrapping: false
21 }
22 }]
23 }
24}複数品目カートインタラクションの項目。
| 項目名 | 項目の型 | 説明 |
|---|---|---|
| lineItems | array | 必須。ゼロ対多の品目データ値の配列 |
| name | string | 必須。イベント名。 |
例
Web SDK を使用してカートインタラクションを取得する例を次に示します。
1SalesforceInteractions.sendEvent({
2 interaction: {
3 name: "Add To Cart",
4 lineItem: {
5 catalogObjectType: "Product",
6 catalogObjectId: "product-1",
7 quantity: 1,
8 price: 9.99,
9 currency: "USD",
10 attributes: {
11 giftWrapping: true
12 }
13 }
14 }
15})サイトマップを使用してカートインタラクションを取得する例を次に示します。
1SalesforceInteractions.init().then(() => {
2 const sitemapConfig = {
3 global: {},
4 pageTypes: [{
5 name: 'product_detail_page',
6 isMatch: () => true,
7 listeners: [
8 SalesforceInteractions.listener("click", ".add-to-cart-button", () => {
9 SalesforceInteractions.sendEvent({
10 interaction: {
11 name: SalesforceInteractions.CartInteractionName.AddToCart,
12 lineItem: {
13 catalogObjectType: "Product",
14 catalogObjectId: "product-1",
15 quantity: 1,
16 price: 9.99,
17 currency: "USD",
18 attributes: {
19 giftWrapping: true
20 }
21 }
22 }
23 })
24 }
25 ]
26 }]
27 }
28 SalesforceInteractions.initSitemap(sitemapConfig)
29})