analytics-plugin-window-events

0.0.7 • Public • Published

Analytics Window Events Plugin

Fire events on window enter and window leave events

Usage

npm install analytics
npm install analytics-plugin-window-events

After installing the plugin, the windowLeft and windowEnter events will fire.

You can listen to these events via additional plugins or with .on & .once listeners.

import Analytics from 'analytics'
import windowEventsPlugin from 'analytics-plugin-window-events'

/* Example plugin that listener to window */
const customWindowListenerPlugin = {
  NAMESPACE: 'custom-window-listener-plugin',
  windowEnter: () => {
    console.log('Window entered do something via plugin')
  },
  windowLeft: () => {
    console.log('Window left do something via plugin')
  }
}

const analytics = Analytics({
  app: 'my-app',
  plugins: [
    windowEventsPlugin(),
    customWindowListenerPlugin
  ]
})

analytics.on('windowEnter', () => {
  // do stuff when visitor enters window
})

analytics.on('windowLeft', () => {
  // do stuff when visitor leaves window
})

Package Sidebar

Install

npm i analytics-plugin-window-events

Weekly Downloads

58

Version

0.0.7

License

MIT

Unpacked Size

64.8 kB

Total Files

11

Last publish

Collaborators

  • davidwells