// After fetching widget data:
const widgetData = {
Data: {
total_count: 2,
items: [
{
sku: 'ABC123',
name: 'Sneakers Pro',
price: 79.99,
brand: 'FitBrand',
product_category: [
{ id: 'cat1', name: 'Shoes', provider_id: 'prov1' }
],
},
// …other items
],
rule_details: {
rule_id: "ABC",
rule_name: "Global Rule for All Instances",
rule_type: "global",
algorithm: "popular_items",
widget_id: "ABC123",
context_type: "global",
context_data: "",
}
}
};
const products = widgetData.Data.items;
const themeCurrency = 'USD';
const pageType = 'product';
const pageMetaId = 'P123';
const pageTitle = 'Sneakers Pro';
ExpAnalyticsService.trackWidgetViewed({
no_of_results: widgetData.Data.total_count,
products_detail: products.map(item => ({
sku: item.sku,
product_category: item.product_category,
})),
rule: widgetData.rule_details.rule_id,
rule_type: widgetData.rule_details.rule_type,
widget_id: widgetData.rule_details.widget_id,
context_type: widgetData.rule_details.context_type,
context_data: widgetData.rule_details.context_data,
category: widgetData.rule_details.category,
page_type: pageType,
page_meta_id: pageMetaId,
page_display_name: pageDisplayName,
});