Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mp-ga-enhancer-ecommerce

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mp-ga-enhancer-ecommerce

E-Commerce enhancer for mp-ga-tracker.

  • 0.1.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mp-ga-enhancer-ecommerce

E-Commerce enhancer for mp-ga-tracker.

Installation

$ npm install mp-ga-enhancer-ecommerce --save

Usage

// import the main SDK, which should be installed separately
import GaTracker from 'mp-ga-tracker'
// import the E-Com enhancer
import * as gaTrackerEcomEnhancer from 'mp-ga-enhancer-ecommerce'

// init the GA tracker
// see more details in the doc of mp-ga-tracker
const gaTracker = new GaTracker(...config)

// inject as the non-first argument of the gaTracker tracking methods that supports the enhancers
// for example, trackScreenview
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([
  {
    // list `nm` is required
    nm: 'Product Impression List Name',
    // ?optional, to specify the index value
    index: 2,
    // the products could be either object or array
    products: {
      // product `id`, `nm`, `ps` are required
      id: 'Product Impression ID',
      nm: 'Product Impression Name',
      ps: 'Product Impression Position',
      // product `pr`, `br`, `ca`, `va` are optional
      pr: 'Product Impression Price',
      br: 'Product Impression Brand',
      ca: 'Product Impression Category',
      va: 'Product Impression Variant',
    },
  },
])

// the argument could be an object as well
impression({
  nm: 'Product Impression List Name',
  products: [],
})

click(Object)

The activity of a product being clicked on.

click({
  pal: 'Product Action List',
  products: {
    // `id`, `nm`, `ps` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    // `pr`, `br`, `ca`, `va`, `qt`, `cc` are optional
    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`, `nm`, `ps` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    // `pr`, `br`, `ca`, `va`, `qt`, `cc` are optional
    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`, `nm`, `ps`, `pr`, `qt` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    pr: 'Product Price',
    qt: 'Product Quantity',
    // `br`, `ca`, `va`, `cc` are optional
    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`, `nm`, `ps`, `pr`, `qt` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    pr: 'Product Price',
    qt: 'Product Quantity',
    // `br`, `ca`, `va`, `cc` are optional
    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`, `col` are optional
  cos: 'Checkout Step',
  col: 'Checkout Option',
  products: {
    // `id`, `nm`, `ps`, `pr`, `qt` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    pr: 'Product Price',
    qt: 'Product Quantity',
    // `br`, `ca`, `va`, `cc` are optional
    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`, `tr` are required
  ti: 'Transaction/Order ID',
  tr: 'Transaction Revenue',
  // `tt`, `ts`, `tcc` are optional
  tt: 'Transaction Tax',
  ts: 'Transaction Shipping',
  tcc: 'Transaction Coupon Code',
  products: {
    // `id`, `nm`, `ps`, `pr`, `qt` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    pr: 'Product Price',
    qt: 'Product Quantity',
    // `br`, `ca`, `va`, `cc` are optional
    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`, `tr` are required
  ti: 'Transaction/Order ID',
  tr: 'Transaction Revenue',
  // `tt`, `ts`, `tcc` are optional
  tt: 'Transaction Tax',
  ts: 'Transaction Shipping',
  tcc: 'Transaction Coupon Code',
  products: {
    // `id`, `nm`, `ps`, `pr`, `qt` are required
    id: 'Product SKU'
    nm: 'Product Name',
    ps: 'Product Position',
    pr: 'Product Price',
    qt: 'Product Quantity',
    // `br`, `ca`, `va`, `cc` are optional
    br: 'Product Brand',
    ca: 'Product Category',
    va: 'Product Variant',
    cc: 'Product Coupon Code',
  },
})

Keywords

FAQs

Package last updated on 19 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc