0.2.3 • Published 5 years ago
analytics-plugin-segment v0.2.3
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.