mp-ga-enhancer-ecommerce
E-Commerce enhancer for mp-ga-tracker.
Installation
$ npm install mp-ga-enhancer-ecommerce --save
Usage
import GaTracker from 'mp-ga-tracker'
import * as gaTrackerEcomEnhancer from 'mp-ga-enhancer-ecommerce'
const gaTracker = new GaTracker(...config)
gaTracker.trackScreenview(
'screen_view',
gaTrackerEcomEnhancer.impression([
index: 2,
nm: 'Product Impression List Name',
products: [
{
id: 'Product Impression SKU',
nm: 'Product Impression Name',
ps: 'Product Impression Position',
},
],
]),
)
API
- All the API supports the
list
and products
type to be either Array
or Object
- While the
<listIndex>
and <productIndex>
would be automatically generated, they could be overridden by simply attaching a specific index value (NOTE: index value should be in the range [1, 200])
impression(Array | Object)
The activity of a product being displayed somewhere, e.g. PLP.
impression([
{
nm: 'Product Impression List Name',
index: 2,
products: {
id: 'Product Impression ID',
nm: 'Product Impression Name',
ps: 'Product Impression Position',
pr: 'Product Impression Price',
br: 'Product Impression Brand',
ca: 'Product Impression Category',
va: 'Product Impression Variant',
},
},
])
impression({
nm: 'Product Impression List Name',
products: [],
})
click(Object)
The activity of a product being clicked on.
click({
pal: 'Product Action List',
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
qt: 'Product Quantity',
cc: 'Product Coupon Code',
},
})
detail(Object)
The activity of a PDP being viewed.
detail({
pal: 'Product Action List',
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
qt: 'Product Quantity',
cc: 'Product Coupon Code',
},
})
add(Object)
The activity of a product being added to cart.
add({
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
qt: 'Product Quantity',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
cc: 'Product Coupon Code',
},
})
remove(Object)
The activity of a product being removed from cart.
remove({
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
qt: 'Product Quantity',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
cc: 'Product Coupon Code',
},
})
checkout(Object)
The activity of a product being checked out.
checkout({
cos: 'Checkout Step',
col: 'Checkout Option',
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
qt: 'Product Quantity',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
cc: 'Product Coupon Code',
},
})
purchase(Object)
The activity of a product being purchased and order being created.
purchase({
ti: 'Transaction/Order ID',
tr: 'Transaction Revenue',
tt: 'Transaction Tax',
ts: 'Transaction Shipping',
tcc: 'Transaction Coupon Code',
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
qt: 'Product Quantity',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
cc: 'Product Coupon Code',
},
})
refund(Object)
The activity of a product and its transaction being refunded.
refund({
ti: 'Transaction/Order ID',
tr: 'Transaction Revenue',
tt: 'Transaction Tax',
ts: 'Transaction Shipping',
tcc: 'Transaction Coupon Code',
products: {
id: 'Product SKU'
nm: 'Product Name',
ps: 'Product Position',
pr: 'Product Price',
qt: 'Product Quantity',
br: 'Product Brand',
ca: 'Product Category',
va: 'Product Variant',
cc: 'Product Coupon Code',
},
})