analytics-plugin-segment

0.2.3 • Public • Published

Segment plugin for analytics

Note: This package has moved to @analytics/segment

Integration with segment for analytics

For more information see the docs.

Usage

Install analytics and @analytics/segment packages

npm install analytics @analytics/segment

Initialize analytics with the segment plugin. After initialization the segment script will be automatically loaded into the page and send data to segment.

import Analytics from 'analytics'
import segmentPlugin from '@analytics/segment'
 
const analytics = Analytics({
  app: 'awesome-app',
  plugins: [
    segmentPlugin({
      writeKey: '123-xyz'
    })
    // ... other plugins
  ]
})
 
/* Track page views */
analytics.page()
 
/* Track custom events */
analytics.track('buttonClicked')
 
/* Identify visitors */
analytics.identify('user-xzy-123', {
  name: 'Bill Murray',
  cool: true
})
 

Plugin Options

Arguments

  • pluginConfig object - Plugin settings
  • pluginConfig.writeKey string - Your segment writeKey
  • [pluginConfig.disableAnonymousTraffic] (optional) boolean - Disable loading segment for anonymous visitors

Example

segmentPlugin({
  writeKey: '123-xyz'
})

See the full list of analytics provider plugins in the main repo.

Package Sidebar

Install

npm i analytics-plugin-segment

Weekly Downloads

2

Version

0.2.3

License

MIT

Unpacked Size

33.8 kB

Total Files

9

Last publish

Collaborators

  • davidwells