products
變數會追蹤產品與相連結的屬性。此變數通常會設定在個別產品頁面、購物車頁面和購買確認頁面上。其為多值變數,這表示您可以在同一次點擊中傳送多個產品,而 Adobe 會將值解析為個別的維度項目。
產品包括 已對應至Adobe Analytics 在數個XDM欄位下:
productListItems[].lineItemId
.productListItems[].SKU
或 productListItems[].name
. 如果兩個XDM欄位均存在, productListItems[].SKU
中所有規則的URL區段。productListItems[].quantity
.productListItems[].priceTotal
.productListItems._experience.analytics.customDimensions.eVars.eVar1
to productListItems._experience.analytics.customDimensions.eVars.eVar250
,取決於您要系結至產品的eVar。productListItems[]._experience.analytics.event1to100.event1.value
to productListItems._experience.analytics.event901to1000.event1000.value
,取決於您要系結至產品的事件。 如果您在其中一個欄位中設定事件,該事件會自動包含在 事件 字串傳送至Adobe Analytics。lineItemId
必須新增為自訂欄位,因為它尚未成為標準Analytics事件結構的一部分。 Adobe計畫未來新增專用的「類別」欄位。
Adobe Experience Platform資料收集中沒有專用欄位可設定此變數;不過,有多個協力廠商擴充功能可提供協助。
您可以使用其中一個擴充功能,或依照下方的 AppMeasurement 語法使用自訂程式碼編輯器。
s.products
變數是字串,其中包含每個產品的多個分隔欄位。 在字串中以分號 (;
) 分隔每個欄位。
currencyCode
變數相符。請勿在此欄位中加入貨幣符號。此欄位僅適用於購買事件的點擊。|
) 分隔多個事件。如需詳細資訊,請參閱事件。|
) 分隔多個銷售 eVar。如需詳細資訊,請參閱銷售 eVar。// Set a single product using all available fields
s.products = "Example category;Example product;1;3.50;event1=4.99|event2=5.99;eVar1=Example merchandising value 1|eVar2=Example merchandising value 2";
此變數支援同一個點擊中的多個產品,因此對於購物車和包含多種產品的購買活動非常有價值。整個 products
字串的長度上限為 64K。 請在字串中以逗號 (,
) 分隔每項產品。
// Set multiple products - useful for when a visitor views their shopping cart
s.products = "Example category 1;Example product 1;1;3.50,Example category 2;Example product 2;1;5.99";
請移除產品名稱、類別和銷售 eVar 值中的所有分號、逗號和垂直號。如果產品名稱包含逗號,AppMeasurement 會將其解析為新產品的開頭。這個錯誤的解析會拋出產品字串剩餘的部分,導致維度和報表中的資料不正確。
在省略欄位及納入多個產品時,products
變數是有彈性的。這種彈性可能會導致您很容易遺漏分隔字元,致使實施傳送錯誤的資料給 Adobe。
// Include only product and category. Common on individual product pages
s.products = "Example category;Example product";
// Include only product name
s.products = ";Example product";
// One product has a category, the other does not. Note the comma and adjacent semicolon to omit category
s.products = "Example category;Example product 1,;Example product 2";
// A visitor purchases a single product; record quantity and price
s.events = "purchase";
s.products = ";Example product;1;6.99";
// A visitor purchases multiple products with different quantities
s.events = "purchase";
s.products = ";Example product 1;9;26.91,Example category;Example product 2;4;9.96";
// Attribute currency event1 only to product 2 and not product 1
s.events = "event1";
s.products = ";Example product 1;1;1.99,Example category 2;Example product 2;1;2.69;event1=1.29";
// Use multiple numeric events in the product string
s.events = "event1,event2";
s.products = ";Example product;1;4.20;event1=2.3|event2=5";
// Use merchandising eVars without any events. Note the adjacent semicolons to skip events
s.products = ";Example product;1;6.69;;eVar1=Merchandising value";
// Use merchandising eVars without category, quantity, price, or events
s.products = ";Example product;;;;eVar1=Merchandising value";
// Multiple products using multiple different events and multiple different merchandising eVars
s.events = "event1,event2,event3,event4,purchase";
s.products = "Example category 1;Example product 1;3;12.60;event1=1.4|event2=9;eVar1=Merchandising value|eVar2=Another merchandising value,Example category 2;Example product 2;1;59.99;event3=6.99|event4=1;eVar3=Merchandising value 3|eVar4=Example value four";
如果使用digitalData
資料層,您可以逐一查看 digitalData.product
物件陣列:
for(var i = 0; i < digitalData.product.length; i++) {
// Add individual product info to the product string
s.products += digitalData.product[i].category.primaryCategory + ";" + digitalData.product[i].productInfo.productName;
// If there are more products, add a comma
if(i != digitalData.product.length - 1) {
s.products += ",";
}
}