[Experimental] Some events work with item properties

mp_event_item(
  item_id = NULL,
  item_name = NULL,
  coupon = NULL,
  discount = NULL,
  affiliation = NULL,
  item_brand = NULL,
  item_category = NULL,
  item_variant = NULL,
  price = NULL,
  currency = NULL
)

Arguments

item_id

Item ID

item_name

Item Name

coupon

Coupon

discount

Discount

affiliation

Affiliation

item_brand

Brand

item_category

Category

item_variant

Variant

price

Price

currency

Currency

Value

An mp_event_item object

See also

Other Measurement Protocol functions: mp_cid(), mp_event(), mp_send()

Examples

# one item
mp_event_item(item_name = "jeggings",
                 price = 8.88,
                 item_variant = "Black")
#> 
#> ==GA4 MP Event Item
#> {
#>   "item_name": "jeggings",
#>   "item_variant": "Black",
#>   "price": 8.88
#> } 

# many items in a list
items <- list(
  mp_event_item(item_id = "SKU_12345",
                price = 9.99,
                item_brand = "Gucci"),
  mp_event_item(item_name = "jeggings",
                price = 8.88,
                item_variant = "Black"))

# construct an event with its own fields
mp_event("add_payment_info",
         params = list(coupon = "SUMMER_FUN",
                       payment_type = "Credit Card",
                       value = 7.77,
                       currency = "USD"),
         items = items)
#> 
#> ==GA4 MP Event
#> {
#>   "name": "add_payment_info",
#>   "params": {
#>     "coupon": "SUMMER_FUN",
#>     "payment_type": "Credit Card",
#>     "value": 7.77,
#>     "currency": "USD",
#>     "items": [
#>       {
#>         "item_id": "SKU_12345",
#>         "item_brand": "Gucci",
#>         "price": 9.99
#>       },
#>       {
#>         "item_name": "jeggings",
#>         "item_variant": "Black",
#>         "price": 8.88
#>       }
#>     ]
#>   }
#> }