מדידת מסחר אלקטרוני

מסחר אלקטרוני מאפשר למדוד אינטראקציות של משתמשים עם מוצרים במהלך חוויית הקנייה שלהם, כולל אינטראקציות כמו צפיות ברשימות מוצרים (פריטים), קליקים ברשימות מוצרים, צפייה בפרטי מוצרים, הוספת מוצר לעגלת קניות, התחלת תהליך התשלום, רכישות והחזרים כספיים.

פרטים על הטמעת אפליקציות אינטרנט למסחר אלקטרוני זמינים במאמר מסחר אלקטרוני ב-Google Analytics.

לפני שמתחילים

חשוב לוודא שהגדרתם את הפרויקט ושיש לכם גישה ל-Analytics, כפי שמתואר במאמר תחילת העבודה עם Analytics. כדי למדוד את המסחר האלקטרוני, צריך לקשר את פרויקט Firebase לחשבון Analytics, ולהשתמש ב-Android SDK בגרסה 17.3.0 או ב-iOS SDK בגרסה 6.20.0 ואילך באפליקציה.

הטמעה

הטמעה רגילה של מסחר אלקטרוני מודדת את הפעולות הבאות:

המוצרים הם הלב של הפעולות האלה. אפשר להטמיע מוצרים כמערך של פריטים שאפשר להוסיף לאירועי מסחר אלקטרוני שנקבעו מראש. אפשר לכלול עד 27 פרמטרים מותאמים אישית במערך הפריטים, בנוסף לפרמטרים שנקבעו מראש.

הדוגמה הבאה ממחישה איך יוצרים מערך של פריטים שאליו נעשה הפנייה במהלך המדריך.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// A pair of jeggings
var jeggings: [String: Any] = [
  AnalyticsParameterItemID: "SKU_123",
  AnalyticsParameterItemName: "jeggings",
  AnalyticsParameterItemCategory: "pants",
  AnalyticsParameterItemVariant: "black",
  AnalyticsParameterItemBrand: "Google",
  AnalyticsParameterPrice: 9.99,
]

// A pair of boots
var boots: [String: Any] = [
  AnalyticsParameterItemID: "SKU_456",
  AnalyticsParameterItemName: "boots",
  AnalyticsParameterItemCategory: "shoes",
  AnalyticsParameterItemVariant: "brown",
  AnalyticsParameterItemBrand: "Google",
  AnalyticsParameterPrice: 24.99,
]

// A pair of socks
var socks: [String: Any] = [
  AnalyticsParameterItemID: "SKU_789",
  AnalyticsParameterItemName: "ankle_socks",
  AnalyticsParameterItemCategory: "socks",
  AnalyticsParameterItemVariant: "red",
  AnalyticsParameterItemBrand: "Google",
  AnalyticsParameterPrice: 5.99,
]

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// A pair of jeggings
NSMutableDictionary *jeggings = [@{
  kFIRParameterItemID: @"SKU_123",
  kFIRParameterItemName: @"jeggings",
  kFIRParameterItemCategory: @"pants",
  kFIRParameterItemVariant: @"black",
  kFIRParameterItemBrand: @"Google",
  kFIRParameterPrice: @9.99,
} mutableCopy];

// A pair of boots
NSMutableDictionary *boots = [@{
  kFIRParameterItemID: @"SKU_456",
  kFIRParameterItemName: @"boots",
  kFIRParameterItemCategory: @"shoes",
  kFIRParameterItemVariant: @"brown",
  kFIRParameterItemBrand: @"Google",
  kFIRParameterPrice: @24.99,
} mutableCopy];

// A pair of socks
NSMutableDictionary *socks = [@{
  kFIRParameterItemID: @"SKU_789",
  kFIRParameterItemName: @"ankle_socks",
  kFIRParameterItemCategory: @"socks",
  kFIRParameterItemVariant: @"red",
  kFIRParameterItemBrand: @"Google",
  kFIRParameterPrice: @5.99,
} mutableCopy];

Kotlin+KTX

val itemJeggings = Bundle().apply {
    putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123")
    putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings")
    putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants")
    putString(FirebaseAnalytics.Param.ITEM_VARIANT, "black")
    putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google")
    putDouble(FirebaseAnalytics.Param.PRICE, 9.99)
}

val itemBoots = Bundle().apply {
    putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_456")
    putString(FirebaseAnalytics.Param.ITEM_NAME, "boots")
    putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "shoes")
    putString(FirebaseAnalytics.Param.ITEM_VARIANT, "brown")
    putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google")
    putDouble(FirebaseAnalytics.Param.PRICE, 24.99)
}

val itemSocks = Bundle().apply {
    putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_789")
    putString(FirebaseAnalytics.Param.ITEM_NAME, "ankle_socks")
    putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "socks")
    putString(FirebaseAnalytics.Param.ITEM_VARIANT, "red")
    putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google")
    putDouble(FirebaseAnalytics.Param.PRICE, 5.99)
}

Java

Bundle itemJeggings = new Bundle();
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_VARIANT, "black");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google");
itemJeggings.putDouble(FirebaseAnalytics.Param.PRICE, 9.99);

Bundle itemBoots = new Bundle();
itemBoots.putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_456");
itemBoots.putString(FirebaseAnalytics.Param.ITEM_NAME, "boots");
itemBoots.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "shoes");
itemBoots.putString(FirebaseAnalytics.Param.ITEM_VARIANT, "brown");
itemBoots.putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google");
itemBoots.putDouble(FirebaseAnalytics.Param.PRICE, 24.99);

Bundle itemSocks = new Bundle();
itemSocks.putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_789");
itemSocks.putString(FirebaseAnalytics.Param.ITEM_NAME, "ankle_socks");
itemSocks.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "socks");
itemSocks.putString(FirebaseAnalytics.Param.ITEM_VARIANT, "red");
itemSocks.putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google");
itemSocks.putDouble(FirebaseAnalytics.Param.PRICE, 5.99);

Web

// A pair of jeggings
const item_jeggings = {
  item_id: 'SKU_123',
  item_name: 'jeggings',
  item_category: 'pants',
  item_variant: 'black',
  item_brand: 'Google',
  price: 9.99
};

// A pair of boots
const item_boots = {
  item_id: 'SKU_456',
  item_name: 'boots',
  item_category: 'shoes',
  item_variant: 'brown',
  item_brand: 'Google',
  price: 24.99
};

// A pair of socks
const item_socks = {
  item_id: 'SKU_789',
  item_name: 'ankle_socks',
  item_category: 'socks',
  item_variant: 'red',
  item_brand: 'Google',
  price: 5.99
};

Web

// A pair of jeggings
const item_jeggings = {
  item_id: 'SKU_123',
  item_name: 'jeggings',
  item_category: 'pants',
  item_variant: 'black',
  item_brand: 'Google',
  price: 9.99
};

// A pair of boots
const item_boots = {
  item_id: 'SKU_456',
  item_name: 'boots',
  item_category: 'shoes',
  item_variant: 'brown',
  item_brand: 'Google',
  price: 24.99
};

// A pair of socks
const item_socks = {
  item_id: 'SKU_789',
  item_name: 'ankle_socks',
  item_category: 'socks',
  item_variant: 'red',
  item_brand: 'Google',
  price: 5.99
};

Dart

// A pair of jeggings
final jeggings = AnalyticsEventItem(
    itemId: "SKU_123",
    itemName: "jeggings",
    itemCategory: "pants",
    itemVariant: "black",
    itemBrand: "Google",
    price: 9.99,
);

// A pair of boots
final boots = AnalyticsEventItem(
    itemId: "SKU_456",
    itemName: "boots",
    itemCategory: "shoes",
    itemVariant: "brown",
    itemBrand: "Google",
    price: 24.99,
);

// A pair of socks
final socks = AnalyticsEventItem(
    itemId: "SKU_789",
    itemName: "ankle_socks",
    itemCategory: "socks",
    itemVariant: "red",
    itemBrand: "Google",
    price: 5.99,
);

בחירת מוצר מתוך רשימה

כשמוצגת למשתמש רשימה של תוצאות, מתעדים אירוע view_item_list שכולל פרמטר מערך items שמכיל את המוצרים שמוצגים.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Add item indexes
jeggings[AnalyticsParameterIndex] = 1
boots[AnalyticsParameterIndex] = 2
socks[AnalyticsParameterIndex] = 3

// Prepare ecommerce parameters
var itemList: [String: Any] = [
  AnalyticsParameterItemListID: "L001",
  AnalyticsParameterItemListName: "Related products",
]

// Add items array
itemList[AnalyticsParameterItems] = [jeggings, boots, socks]

// Log view item list event
Analytics.logEvent(AnalyticsEventViewItemList, parameters: itemList)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Add item indexes
jeggings[kFIRParameterIndex] = @1;
boots[kFIRParameterIndex] = @2;
socks[kFIRParameterIndex] = @3;

// Prepare ecommerce parameters
NSMutableDictionary *itemList = [@{
  kFIRParameterItemListID: @"L001",
  kFIRParameterItemListName: @"Related products",
} mutableCopy];

// Add items array
itemList[kFIRParameterItems] = @[jeggings, boots, socks];

// Log view item list event
[FIRAnalytics logEventWithName:kFIREventViewItemList parameters:itemList];

Kotlin+KTX

val itemJeggingsWithIndex = Bundle(itemJeggings).apply {
    putLong(FirebaseAnalytics.Param.INDEX, 1)
}
val itemBootsWithIndex = Bundle(itemBoots).apply {
    putLong(FirebaseAnalytics.Param.INDEX, 2)
}
val itemSocksWithIndex = Bundle(itemSocks).apply {
    putLong(FirebaseAnalytics.Param.INDEX, 3)
}

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST) {
    param(FirebaseAnalytics.Param.ITEM_LIST_ID, "L001")
    param(FirebaseAnalytics.Param.ITEM_LIST_NAME, "Related products")
    param(
        FirebaseAnalytics.Param.ITEMS,
        arrayOf(itemJeggingsWithIndex, itemBootsWithIndex, itemSocksWithIndex),
    )
}

Java

Bundle itemJeggingsWithIndex = new Bundle(itemJeggings);
itemJeggingsWithIndex.putLong(FirebaseAnalytics.Param.INDEX, 1);

Bundle itemBootsWithIndex = new Bundle(itemBoots);
itemBootsWithIndex.putLong(FirebaseAnalytics.Param.INDEX, 2);

Bundle itemSocksWithIndex = new Bundle(itemSocks);
itemSocksWithIndex.putLong(FirebaseAnalytics.Param.INDEX, 3);

Bundle viewItemListParams = new Bundle();
viewItemListParams.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "L001");
viewItemListParams.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, "Related products");
viewItemListParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsWithIndex, itemBootsWithIndex, itemSocksWithIndex});
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST, viewItemListParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params1 = {
  item_list_id: 'L001',
  item_list_name: 'Related products',
  items: [item_jeggings, item_boots, item_socks]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'view_item_list', params1);

Web

// Prepare ecommerce params
const params1 = {
  item_list_id: 'L001',
  item_list_name: 'Related products',
  items: [item_jeggings, item_boots, item_socks]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_ITEM_LIST, params1);

Dart

await FirebaseAnalytics.instance.logViewItemList(
    itemListId: "L001",
    itemListName: "Related products",
    items: [jeggings, boots, socks],
);

אחרי שמשתמש בוחר מוצר מסוים מהרשימה, מתעדים אירוע select_item עם המוצר שנבחר בפרמטר מערך items.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare ecommerce parameters
var selectedItem: [String: Any] = [
  AnalyticsParameterItemListID: "L001",
  AnalyticsParameterItemListName: "Related products",
]

// Add items array
selectedItem[AnalyticsParameterItems] = [jeggings]

// Log select item event
Analytics.logEvent(AnalyticsEventSelectItem, parameters: selectedItem)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare ecommerce parameters
NSMutableDictionary *selectedItem = [@{
  kFIRParameterItemListID: @"L001",
  kFIRParameterItemListName: @"Related products",
} mutableCopy];

// Add items array
selectedItem[kFIRParameterItems] = @[jeggings];

// Log select item event
[FIRAnalytics logEventWithName:kFIREventSelectItem parameters:selectedItem];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM) {
    param(FirebaseAnalytics.Param.ITEM_LIST_ID, "L001")
    param(FirebaseAnalytics.Param.ITEM_LIST_NAME, "Related products")
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggings))
}

Java

Bundle selectItemParams = new Bundle();
selectItemParams.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "L001");
selectItemParams.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, "Related products");
selectItemParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggings});
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, selectItemParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce event params
const params2 = {
  item_list_id: 'L001',
  item_list_name: 'Related products',
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'select_item', params2);

Web

// Prepare ecommerce event params
const params2 = {
  item_list_id: 'L001',
  item_list_name: 'Related products',
  items: [item_jeggings]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.SELECT_ITEM, params2);

Dart

await FirebaseAnalytics.instance.logSelectItem(
    itemListId: "L001",
    itemListName: "Related products",
    items: [jeggings],
);

לעיון בפרטי המוצר

כדי למדוד את מספר הפעמים שבהן צופים בפרטי המוצר, מתעדים אירוע view_item בכל פעם שמשתמש צופה במסך הפרטים של מוצר.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare ecommerce parameters
var productDetails: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 9.99
]

// Add items array
productDetails[AnalyticsParameterItems] = [jeggings]

// Log view item event
Analytics.logEvent(AnalyticsEventViewItem, parameters: productDetails)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare ecommerce parameters
NSMutableDictionary *productDetails = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @9.99
} mutableCopy];

// Add items array
productDetails[kFIRParameterItems] = @[jeggings];

// Log view item event
[FIRAnalytics logEventWithName:kFIREventViewItem parameters:productDetails];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 9.99)
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggings))
}

Java

Bundle viewItemParams = new Bundle();
viewItemParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
viewItemParams.putDouble(FirebaseAnalytics.Param.VALUE, 9.99);
viewItemParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggings});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, viewItemParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce event params
const params3 = {
  currency: 'USD',
  value: 9.99,
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'view_item', params3);

Web

  // Prepare ecommerce event params
  const params3 = {
    currency: 'USD',
    value: 9.99,
    items: [item_jeggings]
  };

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_ITEM, params3);

Dart

await FirebaseAnalytics.instance.logViewItem(
    currency: 'USD',
    value: 9.99,
    items: [jeggings],
);

הוספה או הסרה של מוצר מעגלת קניות

כדי למדוד הוספה של מוצר לרשימת משאלות או לעגלת קניות, מתעדים אירוע add_to_wishlist או add_to_cart, בהתאמה, עם המוצרים הרלוונטיים בפרמטר מערך items.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Specify order quantity
jeggings[AnalyticsParameterQuantity] = 2

// Prepare item detail params
var itemDetails: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 19.98
]

// Add items
itemDetails[AnalyticsParameterItems] = [jeggings]

// Log an event when product is added to wishlist
Analytics.logEvent(AnalyticsEventAddToWishlist, parameters: itemDetails)

// Log an event when product is added to cart
Analytics.logEvent(AnalyticsEventAddToCart, parameters: itemDetails)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Specify order quantity
jeggings[kFIRParameterQuantity] = @2;

// Prepare item detail params
NSMutableDictionary *itemDetails = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @19.98
} mutableCopy];

// Add items
itemDetails[kFIRParameterItems] = @[jeggings];

// Log an event when product is added to wishlist
[FIRAnalytics logEventWithName:kFIREventAddToWishlist parameters:itemDetails];

// Log an event when product is added to cart
[FIRAnalytics logEventWithName:kFIREventAddToCart parameters:itemDetails];

Kotlin+KTX

val itemJeggingsWishlist = Bundle(itemJeggings).apply {
    putLong(FirebaseAnalytics.Param.QUANTITY, 2)
}

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_WISHLIST) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 2 * 9.99)
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggingsWishlist))
}

Java

Bundle itemJeggingsWishlist = new Bundle(itemJeggings);
itemJeggingsWishlist.putLong(FirebaseAnalytics.Param.QUANTITY, 2);

Bundle addToWishlistParams = new Bundle();
addToWishlistParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
addToWishlistParams.putDouble(FirebaseAnalytics.Param.VALUE, 2 * 9.99);
addToWishlistParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsWishlist});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_WISHLIST, addToWishlistParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Specify order quantity
const item_jeggings_quantity = {
  ...item_jeggings,
  quantity: 2
};

// Prepare ecommerce bundle
const params4 = {
  currency: 'USD',
  value: 19.98,
  items: [item_jeggings_quantity]
};

// Log event when a product is added to a wishlist
const analytics = getAnalytics();
logEvent(analytics, 'add_to_wishlist', params4);

// Log event when a product is added to the cart
logEvent(analytics, 'add_to_cart', params4);

Web

// Specify order quantity
const item_jeggings_quantity = {
  ...item_jeggings,
  quantity: 2
};

// Prepare ecommerce bundle
const params4 = {
  currency: 'USD',
  value: 19.98,
  items: [item_jeggings_quantity]
};

// Log event when a product is added to a wishlist
firebase.analytics().logEvent(firebase.analytics.EventName.ADD_TO_WISHLIST, params4);

// Log event when a product is added to the cart
firebase.analytics().logEvent(firebase.analytics.EventName.ADD_TO_CART, params4);

Dart

final jeggingsWithQuantity = AnalyticsEventItem(
    itemId: jeggings.itemId,
    itemName: jeggings.itemName,
    itemCategory: jeggings.itemCategory,
    itemVariant: jeggings.itemVariant,
    itemBrand: jeggings.itemBrand,
    price: jeggings.price,
    quantity: 2,
);
await FirebaseAnalytics.instance.logAddToWishlist(
    currency: 'USD',
    value: 19.98,
    items: [jeggingsWithQuantity],
);
await FirebaseAnalytics.instance.logAddToCart(
    currency: 'USD',
    value: 19.98,
    items: [jeggingsWithQuantity],
);

כשמשתמש צופה בעגלה לאחר מכן, מתעדים ביומן את האירוע view_cart עם כל items שבעגלה.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Specify order quantity
jeggings[AnalyticsParameterQuantity] = 2
boots[AnalyticsParameterQuantity] = 1

// Prepare order parameters
var orderParameters: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 44.97
]

// Add items array
orderParameters[AnalyticsParameterItems] = [jeggings, boots]

// Log event when cart is viewed
Analytics.logEvent(AnalyticsEventViewCart, parameters: orderParameters)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Specify order quantity
jeggings[kFIRParameterQuantity] = @2;
boots[kFIRParameterQuantity] = @1;

// Prepare order parameters
NSMutableDictionary *orderParameters = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @44.97
} mutableCopy];

// Add items array
orderParameters[kFIRParameterItems] = @[jeggings, boots];

// Log event when cart is viewed
[FIRAnalytics logEventWithName:kFIREventViewCart parameters:orderParameters];

Kotlin+KTX

val itemJeggingsCart = Bundle(itemJeggings).apply {
    putLong(FirebaseAnalytics.Param.QUANTITY, 2)
}
val itemBootsCart = Bundle(itemBoots).apply {
    putLong(FirebaseAnalytics.Param.QUANTITY, 1)
}

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_CART) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 2 * 9.99 + 1 * 24.99)
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggingsCart, itemBootsCart))
}

Java

Bundle itemJeggingsCart = new Bundle(itemJeggings);
itemJeggingsCart.putLong(FirebaseAnalytics.Param.QUANTITY, 2);

Bundle itemBootsCart = new Bundle(itemBoots);
itemBootsCart.putLong(FirebaseAnalytics.Param.QUANTITY, 1);

Bundle viewCartParams = new Bundle();
viewCartParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
viewCartParams.putDouble(FirebaseAnalytics.Param.VALUE, (2 * 9.99) + (1 * 24.99));
viewCartParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsCart, itemBootsCart});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_CART, viewCartParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Specify order quantity
const item_jeggings_quantity = {
  ...item_jeggings,
  quantity: 2
};

const item_boots_quantity = {
  ...item_boots,
  quantity: 1
};

// Prepare ecommerce params
const params5 = {
  currency: 'USD',
  value: 44.97,
  items: [item_jeggings_quantity, item_boots_quantity]
};

// Log event when the cart is viewed
const analytics = getAnalytics();
logEvent(analytics, 'view_cart', params5);

Web

// Specify order quantity
const item_jeggings_quantity = {
  ...item_jeggings,
  quantity: 2
};

const item_boots_quantity = {
  ...item_boots,
  quantity: 1
};

// Prepare ecommerce params
const params5 = {
  currency: 'USD',
  value: 44.97,
  items: [item_jeggings_quantity, item_boots_quantity]
};

// Log event when the cart is viewed
firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_CART, params5);

Dart

await FirebaseAnalytics.instance.logViewCart(
    currency: 'USD',
    value: 19.98,
    items: [jeggingsWithQuantity],
);

כדי למדוד מתי משתמש מסיר מוצר מעגלת הקניות, מתעדים את האירוע remove_from_cart.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Specify removal quantity
boots[AnalyticsParameterQuantity] = 1

// Prepare params
var removeParams: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 24.99
]

// Add items
removeParams[AnalyticsParameterItems] = [boots]

// Log removal event
Analytics.logEvent(AnalyticsEventRemoveFromCart, parameters: removeParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Specify removal quantity
boots[kFIRParameterQuantity] = @1;

// Prepare params
NSMutableDictionary *removeParams = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @24.99
} mutableCopy];

// Add items
removeParams[kFIRParameterItems] = @[boots];

// Log removal event
[FIRAnalytics logEventWithName:kFIREventRemoveFromCart parameters:removeParams];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.REMOVE_FROM_CART) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 1 * 24.99)
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemBootsCart))
}

Java

Bundle removeCartParams = new Bundle();
removeCartParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
removeCartParams.putDouble(FirebaseAnalytics.Param.VALUE, (1 * 24.99));
removeCartParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemBootsCart});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.REMOVE_FROM_CART, removeCartParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params6 = {
  currency: 'USD',
  value: 24.99,
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'remove_from_cart', params6);

Web

// Prepare ecommerce params
const params6 = {
  currency: 'USD',
  value: 24.99,
  items: [item_jeggings]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.REMOVE_FROM_CART, params6);

Dart

final jeggingsWithQuantity = AnalyticsEventItem(
    itemId: jeggings.itemId,
    itemName: jeggings.itemName,
    itemCategory: jeggings.itemCategory,
    itemVariant: jeggings.itemVariant,
    itemBrand: jeggings.itemBrand,
    price: jeggings.price,
    quantity: 1,
);
await FirebaseAnalytics.instance.logRemoveFromCart(
    currency: 'USD',
    value: 9.99,
    items: [jeggingsWithQuantity],
);

התחלת תהליך התשלום

כדי למדוד את השלב הראשון בתהליך התשלום, מתעדים אירוע begin_checkout עם items אחד או יותר שמוגדרים עם השדות הרלוונטיים. בשלב הזה אפשר גם להוסיף שובר לכל ההזמנה על ידי הוספה שלו לאירוע, או להחיל אותו על פריט מסוים על ידי הוספה שלו לרכיבים ספציפיים במערך items.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare checkout params
var checkoutParams: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 14.98,
  AnalyticsParameterCoupon: "SUMMER_FUN"
];

// Add items
checkoutParams[AnalyticsParameterItems] = [jeggings]

// Log checkout event
Analytics.logEvent(AnalyticsEventBeginCheckout, parameters: checkoutParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare checkout params
NSMutableDictionary *checkoutParams = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @14.98,
  kFIRParameterCoupon: @"SUMMER_FUN"
} mutableCopy];

// Add items
checkoutParams[kFIRParameterItems] = @[jeggings];

// Log checkout event
[FIRAnalytics logEventWithName:kFIREventBeginCheckout parameters:checkoutParams];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.BEGIN_CHECKOUT) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 14.98)
    param(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN")
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggingsCart))
}

Java

Bundle beginCheckoutParams = new Bundle();
beginCheckoutParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
beginCheckoutParams.putDouble(FirebaseAnalytics.Param.VALUE, 14.98);
beginCheckoutParams.putString(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN");
beginCheckoutParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsCart});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.BEGIN_CHECKOUT, beginCheckoutParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params7 = {
  currency: 'USD',
  value: 14.98, // Total Revenue
  coupon: 'SUMMER_FUN',
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'begin_checkout', params7);

Web

// Prepare ecommerce params
const params7 = {
  currency: 'USD',
  value: 14.98, // Total Revenue
  coupon: 'SUMMER_FUN',
  items: [item_jeggings]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.BEGIN_CHECKOUT, params7);

Dart

await FirebaseAnalytics.instance.logBeginCheckout(
    currency: 'USD',
    value: 15.98,  // Discount applied.
    coupon: "SUMMER_FUN",
    items: [jeggingsWithQuantity],
);

כשמשתמש עובר לשלב הבא בתהליך התשלום ומוסיף פרטי משלוח, צריך לתעד אירוע add_shipping_info. משתמשים בפרמטר shipping_tier כדי לציין את אפשרות המשלוח של המשתמש, למשל 'יבשתי', 'אווירי' או 'ביום המחרת'.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare shipping params
var shippingParams: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 14.98,
  AnalyticsParameterCoupon: "SUMMER_FUN",
  AnalyticsParameterShippingTier: "Ground"
]

// Add items
shippingParams[AnalyticsParameterItems] = [jeggings]

// Log added shipping info event
Analytics.logEvent(AnalyticsEventAddShippingInfo, parameters: shippingParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare shipping params
NSMutableDictionary *shippingParams = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @14.98,
  kFIRParameterCoupon: @"SUMMER_FUN",
  kFIRParameterShippingTier: @"Ground"
} mutableCopy];

// Add items
shippingParams[kFIRParameterItems] = @[jeggings];

// Log added shipping info event
[FIRAnalytics logEventWithName:kFIREventAddShippingInfo parameters:shippingParams];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_SHIPPING_INFO) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 14.98)
    param(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN")
    param(FirebaseAnalytics.Param.SHIPPING_TIER, "Ground")
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggingsCart))
}

Java

Bundle addShippingParams = new Bundle();
addShippingParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
addShippingParams.putDouble(FirebaseAnalytics.Param.VALUE, 14.98);
addShippingParams.putString(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN");
addShippingParams.putString(FirebaseAnalytics.Param.SHIPPING_TIER, "Ground");
addShippingParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsCart});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_SHIPPING_INFO, addShippingParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params8 = {
  currency: 'USD',
  value: 14.98, // Total Revenue
  coupon: 'SUMMER_FUN',
  shipping_tier: 'Ground',
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'add_shipping_info', params8);

Web

// Prepare ecommerce params
const params8 = {
  currency: 'USD',
  value: 14.98, // Total Revenue
  coupon: 'SUMMER_FUN',
  shipping_tier: 'Ground',
  items: [item_jeggings]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.ADD_SHIPPING_INFO, params8);

Dart

await FirebaseAnalytics.instance.logAddShippingInfo(
    currency: 'USD',
    value: 15.98,
    coupon: "SUMMER_FUN",
    shippingTier: "Ground",
    items: [jeggingsWithQuantity],
);

הוספת האירוע add_payment_info ביומן כשמשתמש שולח את פרטי התשלום שלו. אם רלוונטי, צריך לכלול את השדה payment_type באירוע הזה עבור אמצעי התשלום שנבחר.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare payment params
var paymentParams: [String: Any] = [
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 14.98,
  AnalyticsParameterCoupon: "SUMMER_FUN",
  AnalyticsParameterPaymentType: "Visa"
]

// Add items
paymentParams[AnalyticsParameterItems] = [jeggings]

// Log added payment info event
Analytics.logEvent(AnalyticsEventAddPaymentInfo, parameters: paymentParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare payment params
NSMutableDictionary *paymentParams = [@{
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @14.98,
  kFIRParameterCoupon: @"SUMMER_FUN",
  kFIRParameterPaymentType: @"Visa"
} mutableCopy];

// Add items
paymentParams[kFIRParameterItems] = @[jeggings];

// Log added payment info event
[FIRAnalytics logEventWithName:kFIREventAddPaymentInfo parameters:paymentParams];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_PAYMENT_INFO) {
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 14.98)
    param(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN")
    param(FirebaseAnalytics.Param.PAYMENT_TYPE, "Visa")
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggingsCart))
}

Java

Bundle addPaymentParams = new Bundle();
addPaymentParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
addPaymentParams.putDouble(FirebaseAnalytics.Param.VALUE, 14.98);
addPaymentParams.putString(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN");
addPaymentParams.putString(FirebaseAnalytics.Param.PAYMENT_TYPE, "Visa");
addPaymentParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsCart});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_PAYMENT_INFO, addPaymentParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params9 = {
  currency: 'USD',
  value: 14.98, // Total Revenue
  coupon: 'SUMMER_FUN',
  payment_type: 'Visa',
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'add_payment_info', params9);  

Web

// Prepare ecommerce params
const params9 = {
  currency: 'USD',
  value: 14.98, // Total Revenue
  coupon: 'SUMMER_FUN',
  payment_type: 'Visa',
  items: [item_jeggings]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.ADD_PAYMENT_INFO, params9);  

Dart

await FirebaseAnalytics.instance.logAddPaymentInfo(
    currency: 'USD',
    value: 15.98,
    coupon: "SUMMER_FUN",
    paymentType: "Visa",
    items: [jeggingsWithQuantity],
);

ביצוע רכישה או הנפקת החזר כספי

כדי למדוד רכישה, מתעדים אירוע purchase עם items אחד או יותר שמוגדרים עם השדות הרלוונטיים.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare purchase params
var purchaseParams: [String: Any] = [
  AnalyticsParameterTransactionID: "T12345",
  AnalyticsParameterAffiliation: "Google Store",
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 14.98,
  AnalyticsParameterTax: 2.58,
  AnalyticsParameterShipping: 5.34,
  AnalyticsParameterCoupon: "SUMMER_FUN"
]

// Add items
purchaseParams[AnalyticsParameterItems] = [jeggings]

// Log purchase event
Analytics.logEvent(AnalyticsEventPurchase, parameters: purchaseParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare purchase params
NSMutableDictionary *purchaseParams = [@{
  kFIRParameterTransactionID: @"T12345",
  kFIRParameterAffiliation: @"Google Store",
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @14.98,
  kFIRParameterTax: @2.58,
  kFIRParameterShipping: @5.34,
  kFIRParameterCoupon: @"SUMMER_FUN"
} mutableCopy];

// Add items
purchaseParams[kFIRParameterItems] = @[jeggings];

// Log purchase event
[FIRAnalytics logEventWithName:kFIREventPurchase parameters:purchaseParams];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.PURCHASE) {
    param(FirebaseAnalytics.Param.TRANSACTION_ID, "T12345")
    param(FirebaseAnalytics.Param.AFFILIATION, "Google Store")
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 14.98)
    param(FirebaseAnalytics.Param.TAX, 2.58)
    param(FirebaseAnalytics.Param.SHIPPING, 5.34)
    param(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN")
    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggingsCart))
}

Java

Bundle purchaseParams = new Bundle();
purchaseParams.putString(FirebaseAnalytics.Param.TRANSACTION_ID, "T12345");
purchaseParams.putString(FirebaseAnalytics.Param.AFFILIATION, "Google Store");
purchaseParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
purchaseParams.putDouble(FirebaseAnalytics.Param.VALUE, 14.98);
purchaseParams.putDouble(FirebaseAnalytics.Param.TAX, 2.58);
purchaseParams.putDouble(FirebaseAnalytics.Param.SHIPPING, 5.34);
purchaseParams.putString(FirebaseAnalytics.Param.COUPON, "SUMMER_FUN");
purchaseParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggingsCart});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.PURCHASE, purchaseParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce bundle
const params10 = {
  transaction_id: 'T12345',
  affiliation: 'Google Store',
  currency: 'USD',
  value: 14.98, // Total Revenue
  tax: 2.85,
  shipping: 5.34,
  coupon: 'SUMMER_FUN',
  items: [item_jeggings]
};

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'purchase', params10);

Web

// Prepare ecommerce bundle
const params10 = {
  transaction_id: 'T12345',
  affiliation: 'Google Store',
  currency: 'USD',
  value: 14.98, // Total Revenue
  tax: 2.85,
  shipping: 5.34,
  coupon: 'SUMMER_FUN',
  items: [item_jeggings]
};

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.PURCHASE, params10);

Dart

await FirebaseAnalytics.instance.logPurchase(
    transactionId: "12345",
    affiliation: "Google Store",
    currency: 'USD',
    value: 15.98,
    shipping: 2.00,
    tax: 1.66,
    coupon: "SUMMER_FUN",
    items: [jeggingsWithQuantity],
);

כדי למדוד החזרים כספיים, מתעדים אירוע refund עם הערך הרלוונטי של transaction_id, ואם רוצים, גם אירוע items אחד או יותר שמוגדרים באמצעות item_id ו-quantity. מומלץ לכלול פרטי פריטים באירוע refund כדי לראות מדדי החזרים כספיים ברמת הפריט ב-Analytics.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare refund params
var refundParams: [String: Any] = [
  AnalyticsParameterTransactionID: "T12345",
  AnalyticsParameterCurrency: "USD",
  AnalyticsParameterValue: 9.99,
]

// (Optional) for partial refunds, define the item ID and quantity of refunded items
let refundedProduct: [String: Any] = [
  AnalyticsParameterItemID: "SKU_123",
  AnalyticsParameterQuantity: 1,
];

// Add items
refundParams[AnalyticsParameterItems] = [refundedProduct]

// Log refund event
Analytics.logEvent(AnalyticsEventRefund, parameters: refundParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare refund params
NSMutableDictionary *refundParams = [@{
  kFIRParameterTransactionID: @"T12345",
  kFIRParameterCurrency: @"USD",
  kFIRParameterValue: @9.99,
} mutableCopy];

// (Optional) for partial refunds, define the item ID and quantity of refunded items
NSDictionary *refundedProduct = @{
  kFIRParameterItemID: @"SKU_123",
  kFIRParameterQuantity: @1,
};

// Add items
refundParams[kFIRParameterItems] = @[refundedProduct];

// Log refund event
[FIRAnalytics logEventWithName:kFIREventRefund parameters:refundParams];

Kotlin+KTX

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.REFUND) {
    param(FirebaseAnalytics.Param.TRANSACTION_ID, "T12345")
    param(FirebaseAnalytics.Param.AFFILIATION, "Google Store")
    param(FirebaseAnalytics.Param.CURRENCY, "USD")
    param(FirebaseAnalytics.Param.VALUE, 9.99)

    // (Optional) for partial refunds, define the item ID and quantity of refunded items
    param(FirebaseAnalytics.Param.ITEM_ID, "SKU_123")
    param(FirebaseAnalytics.Param.QUANTITY, 1)

    param(FirebaseAnalytics.Param.ITEMS, arrayOf(itemJeggings))
}

Java

Bundle refundParams = new Bundle();
refundParams.putString(FirebaseAnalytics.Param.TRANSACTION_ID, "T12345");
refundParams.putString(FirebaseAnalytics.Param.AFFILIATION, "Google Store");
refundParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
refundParams.putDouble(FirebaseAnalytics.Param.VALUE, 9.99);

// (Optional) for partial refunds, define the item ID and quantity of refunded items
refundParams.putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123");
refundParams.putLong(FirebaseAnalytics.Param.QUANTITY, 1);

refundParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggings});

mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.REFUND, refundParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params11 = {
  transaction_id: 'T12345', // Required
  affiliation: 'Google Store',
  currency: 'USD',
  value: 9.99,
  items: []
};

// (Optional) For partial refunds, define the item_id and quantity of refunded items
const refundedProduct = {
  item_id: 'SKU_123', // Required
  quantity: 1 // Required
};

params11.items.push(refundedProduct);

// Log event
const analytics = getAnalytics();
logEvent(analytics, 'refund', params11);

Web

// Prepare ecommerce params
const params11 = {
  transaction_id: 'T12345', // Required
  affiliation: 'Google Store',
  currency: 'USD',
  value: 9.99,
  items: []
};

// (Optional) For partial refunds, define the item_id and quantity of refunded items
const refundedProduct = {
  item_id: 'SKU_123', // Required
  quantity: 1 // Required
};

params11.items.push(refundedProduct);

// Log event
firebase.analytics().logEvent(firebase.analytics.EventName.REFUND, params11);

Dart

await FirebaseAnalytics.instance.logRefund(
    transactionId: "12345",
    affiliation: "Google Store",
    currency: 'USD',
    value: 15.98,
    items: [jeggingsWithQuantity],
);

החלת מבצעים

ב-Google שופינג יש תמיכה במדידת חשיפות וקליקים של קידומי מכירות פנימיים, כמו מודעות באנר שמוצגות כדי לקדם מכירה.

בדרך כלל, החשיפות של קידום המכירות נמדדות לפי תצוגת המסך הראשונית. לשם כך, מתעדים את האירוע view_promotion עם הפרמטר items כדי לציין את המוצר לקידום. כדי לציין שמשתמש לחץ על קידום מכירות, רושמים ביומן אירוע select_promotion עם המוצר הזה כפרמטר item.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare promotion parameters
var promoParams: [String: Any] = [
  AnalyticsParameterPromotionID: "T12345",
  AnalyticsParameterPromotionName:"Summer Sale",
  AnalyticsParameterCreativeName: "summer2020_promo.jpg",
  AnalyticsParameterCreativeSlot: "featured_app_1",
  AnalyticsParameterLocationID: "HERO_BANNER",
]

// Add items
promoParams[AnalyticsParameterItems] = [jeggings]

// Log event when promotion is displayed
Analytics.logEvent(AnalyticsEventViewPromotion, parameters: promoParams)

// Log event when promotion is selected
Analytics.logEvent(AnalyticsEventSelectPromotion, parameters: promoParams)

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// Prepare promotion parameters
NSMutableDictionary *promoParams = [@{
  kFIRParameterPromotionID: @"T12345",
  kFIRParameterPromotionName: @"Summer Sale",
  kFIRParameterCreativeName: @"summer2020_promo.jpg",
  kFIRParameterCreativeSlot: @"featured_app_1",
  kFIRParameterLocationID: @"HERO_BANNER",
} mutableCopy];

// Add items
promoParams[kFIRParameterItems] = @[jeggings];

// Log event when promotion is displayed
[FIRAnalytics logEventWithName:kFIREventViewPromotion parameters:promoParams];

// Log event when promotion is selected
[FIRAnalytics logEventWithName:kFIREventSelectPromotion parameters:promoParams];

Kotlin+KTX

val promoParams = Bundle().apply {
    putString(FirebaseAnalytics.Param.PROMOTION_ID, "SUMMER_FUN")
    putString(FirebaseAnalytics.Param.PROMOTION_NAME, "Summer Sale")
    putString(FirebaseAnalytics.Param.CREATIVE_NAME, "summer2020_promo.jpg")
    putString(FirebaseAnalytics.Param.CREATIVE_SLOT, "featured_app_1")
    putString(FirebaseAnalytics.Param.LOCATION_ID, "HERO_BANNER")
    putParcelableArray(FirebaseAnalytics.Param.ITEMS, arrayOf<Parcelable>(itemJeggings))
}

// Promotion displayed
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_PROMOTION, promoParams)

// Promotion selected
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_PROMOTION, promoParams)

Java

Bundle promoParams = new Bundle();
promoParams.putString(FirebaseAnalytics.Param.PROMOTION_ID, "SUMMER_FUN");
promoParams.putString(FirebaseAnalytics.Param.PROMOTION_NAME, "Summer Sale");
promoParams.putString(FirebaseAnalytics.Param.CREATIVE_NAME, "summer2020_promo.jpg");
promoParams.putString(FirebaseAnalytics.Param.CREATIVE_SLOT, "featured_app_1");
promoParams.putString(FirebaseAnalytics.Param.LOCATION_ID, "HERO_BANNER");
promoParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS,
        new Parcelable[]{itemJeggings});

// Promotion displayed
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_PROMOTION, promoParams);

// Promotion selected
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_PROMOTION, promoParams);

Web

import { getAnalytics, logEvent } from "firebase/analytics";

// Prepare ecommerce params
const params12 = {
  promotion_id: 'ABC123',
  promotion_name: 'Summer Sale',
  creative_name: 'summer2020_promo.jpg',
  creative_slot: 'featured_app_1',
  location_id: 'HERO_BANNER',
  items: [item_jeggings]
};

// Log event when a promotion is displayed
const analytics = getAnalytics();
logEvent(analytics, 'view_promotion', params12);

// Log event when a promotion is selected
logEvent(analytics, 'select_promotion', params12);

Web

// Prepare ecommerce params
const params12 = {
  promotion_id: 'ABC123',
  promotion_name: 'Summer Sale',
  creative_name: 'summer2020_promo.jpg',
  creative_slot: 'featured_app_1',
  location_id: 'HERO_BANNER',
  items: [item_jeggings]
};

// Log event when a promotion is displayed
firebase.analytics().logEvent(firebase.analytics.EventName.VIEW_PROMOTION, params12);

// Log event when a promotion is selected
firebase.analytics().logEvent(firebase.analytics.EventName.SELECT_PROMOTION, params12);

Dart

await FirebaseAnalytics.instance.logViewPromotion(
    promotionId: "SUMMER_FUN",
    promotionName: "Summer Sale",
    creativeName: "summer2020_promo.jpg",
    creativeSlot: "featured_app_1",
    locationId: "HERO_BANNER",
);

await FirebaseAnalytics.instance.logSelectPromotion(
    promotionId: "SUMMER_FUN",
    promotionName: "Summer Sale",
    creativeName: "summer2020_promo.jpg",
    creativeSlot: "featured_app_1",
    locationId: "HERO_BANNER",
);

שליחת פרמטרים מותאמים אישית ברמת הפריט

פרמטר מותאם אישית ברמת הפריט הוא פרמטר שאינו אחד מהפרמטרים ש-Google כוללת ברשימת הפרמטרים הנדרשים או האופציונליים של פריט מסחר אלקטרוני. הפרמטר המותאם אישית מאפשר לכם לאסוף מידע על פריט ששימושי לעסק הספציפי שלכם.

מהאפליקציה, אפשר לשלוח עד 27 פרמטרים מותאמים אישית ברמת הפריט במערך הפריטים, ומתוכם אפשר להגדיר 10 מאפיינים מותאמים אישית ברמת הפריט לנכסים רגילים ו-25 לנכסי Analytics 360. כך תוכלו לבחור מתוך מאגר גדול יותר של פרמטרים בלי שתצטרכו לתייג מחדש את האפליקציה.

Swift

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// A pair of jeggings
var jeggings: [String: Any] = [
  AnalyticsParameterItemID: "SKU_123",
  AnalyticsParameterItemName: "jeggings",
  AnalyticsParameterItemCategory: "pants",
  AnalyticsParameterItemVariant: "black",
  AnalyticsParameterItemBrand: "Google",
  AnalyticsParameterPrice: 9.99,
  AnalyticsParameterItemColor: "blue", // The item-scoped custom parameter
]

Objective-C

הערה: מוצר Firebase הזה לא זמין ביעד macOS.
// A pair of jeggings
NSMutableDictionary *jeggings = [@{
  kFIRParameterItemID: @"SKU_123",
  kFIRParameterItemName: @"jeggings",
  kFIRParameterItemCategory: @"pants",
  kFIRParameterItemVariant: @"black",
  kFIRParameterItemBrand: @"Google",
  kFIRParameterPrice: @9.99,
  kFIRParameterItemColor: @"blue", // The item-scoped custom parameter
} mutableCopy];

Kotlin+KTX

val itemJeggings = Bundle().apply {
  putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123")
  putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings")
  putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants")
  putString(FirebaseAnalytics.Param.ITEM_VARIANT, "black")
  putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google")
  putDouble(FirebaseAnalytics.Param.PRICE, 9.99)
  putString(FirebaseAnalytics.Param.ITEM_COLOR, "blue") // The item-scoped custom parameter
}

Java

Bundle itemJeggings = new Bundle();
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_VARIANT, "black");
itemJeggings.putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google");
itemJeggings.putDouble(FirebaseAnalytics.Param.PRICE, 9.99);
itemJeggings.putDouble(FirebaseAnalytics.Param.ITEM_COLOR, 9.99); // The item-scoped custom parameter

Web

// A pair of jeggings
const item_jeggings = {
  item_id: 'SKU_123',
  item_name: 'jeggings',
  item_category: 'pants',
  item_variant: 'black',
  item_brand: 'Google',
  price: 9.99,
  item_color: 'blue' // The item-scoped custom parameter
};

Web

// A pair of jeggings
const item_jeggings = {
  item_id: 'SKU_123',
  item_name: 'jeggings',
  item_category: 'pants',
  item_variant: 'black',
  item_brand: 'Google',
  price: 9.99,
  item_color: 'blue' // The item-scoped custom parameter
};

Dart

// A pair of jeggings
final jeggings = AnalyticsEventItem(
    itemId: "SKU_123",
    itemName: "jeggings",
    itemCategory: "pants",
    itemVariant: "black",
    itemBrand: "Google",
    price: 9.99,
    itemColor: "blue", // The item-scoped custom parameter
);