gmr_enhanced_ecom: Build Enhanced Ecommerce hits

Description Usage Arguments Details Value Examples

View source: R/ecommerce.R

Description

A helper function to build enhanced ecommerce hits

Usage

1
2
3
4
5
gmr_enhanced_ecom(action = c("purchase", "detail", "click", "add", "remove",
  "checkout", "checkout_option", "purchase", "refund"), transaction_id,
  revenue = NULL, product_sku = NULL, product_name = NULL,
  product_brand = NULL, product_category = NULL, product_price = NULL,
  ...)

Arguments

action

The role of the products included in a hit. Required.

transaction_id

An id for the transaction. Required.

revenue

The total value of the transaction

product_sku

A vector of product SKU

product_name

A vector of product names

product_brand

A vector of product brands

product_category

A vector of product category

product_price

A vector of product price

Details

This lets you more easily create enhanced ecommerce hits by creating an object you then pass into other hits such as gmr_hit_event

The product arguments such as product_sku are vectors that will be turned into lists via gmr_enhanced_index. If passing multiple arguments, they each must have the products in the same order and be the same length.

If you want to pass your own indexed products, gmr_enhanced_index can be used to create a named list which you can then append to the paramters generated using do.call. See examples.

Value

An gmr_ee object that can be passed to gmr_hit_x functions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
gmr_hit_page(url_path = "/checkout",
             enhanced_ecom = gmr_enhanced_ecom("purchase", transaction_id = "blah223", revenue = 4300.23, product_sku = c("sku4","sku23","sku7")))

# Make your own hit
my_promotion_id <- gmr_enhanced_index(c("aff3","aff2","aff2"), prefix = "promo", suffix = "id")

# make your own enhanced ecom obj
my_ee <- do.call(gmr_enhanced_ecom,
                 args = c(list(action = "purchase",
                              transaction_id = "2323",
                              product_sku = c("sku4","sku3","sku7")
                              ),
                         my_promotion_id)
                         )

# register hit
gmr_hit_page(url_path = "/checkout-thanks", enhanced_ecom = my_ee)

MarkEdmondson1234/googleMeasureR documentation built on Oct. 27, 2019, 9:02 p.m.