@botonic/plugin-segment

0.25.0 • Public • Published

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

  1. Run npm install --save @botonic/plugin-segment to install the plugin.
  2. Add it to the src/plugins.js file:

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 track a 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: 'peter@domain.com', 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 })
  }

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @botonic/plugin-segment

    Weekly Downloads

    140

    Version

    0.25.0

    License

    MIT

    Unpacked Size

    4.2 kB

    Total Files

    4

    Last publish

    Collaborators

    • oraventos
    • agimenezhubtype
    • ahubstre
    • ericmarcos
    • khaeshah
    • mrabat
    • elozano
    • ainavendrell