@botonic/plugin-segment
v0.42.0
Published
This plugin uses [Segment](https://segment.com/) to clean, collect and control customer data. It helps monitor performance, define decision-making processes and identify customers' interests.
Downloads
290
Readme
Botonic Plugin Segment
What Does This Plugin Do?
This plugin uses Segment to clean, collect and control customer data. It helps monitor performance, define decision-making processes and identify customers' interests.
Setup
- Run
npm install --save @botonic/plugin-segmentto install the plugin. - Add it to the
src/plugins.jsfile:
src/plugins.js
export const plugins = [
{
id: 'segment',
resolve: require('@botonic/plugin-segment'),
options: {
writeKey: 'YOUR_WRITE_KEY',
},
},
]Use
The default behavior of this plugin is to:
- Identify the user during the first bot interaction.
- Track
tracka page event to Segment from then on.
If you prefer to track your events manually, you can add the flag trackManually: true in your options. Once set, you can use them inside the method botonicInit on each Botonic component you want to track:
static async botonicInit({ input, session, params, lastRoutePath, plugins }) {
let { segment } = plugins
let userId = session.user.id
let event = 'This is the name of the current event I'm tracking'
let traits = { name: 'Peter', email: '[email protected]', plan: 'premium' }
await segment.identify({
input,
session,
userId: userId,
traits: traits
})
let properties = {
name: "Some interesting data",
value: "14.99"
}
await segment.track({ input, session, userId: userId, event, properties })
}