Files
medusa-store/packages/medusa-plugin-segment
Oliver Windall Juhl afd1b67f1c chore: Clean up deps, devDeps, and peerDeps across all packages (#4276)
* chore: Use caret for all Medusa deps

* Create wild-balloons-push.md

* Address PR feedback

* force build order

* add missing dep

* add missing dev deps

* addresses last comments
2023-06-14 15:18:11 +02:00
..
2022-03-24 16:47:50 +01:00
2023-04-04 18:35:27 +02:00

Segment

Track essential commerce analytics with Segment.

Segment Plugin Documentation | Medusa Website | Medusa Repository

Features

  • Automatic analytics tracking for events related to Orders, Swaps, and Claims.
  • Flexibility to track analytics for custom events or operations.

Prerequisites


How to Install

1. Run the following command in the directory of the Medusa backend:

npm install medusa-plugin-segment

2. Set the following environment variable in .env:

SEGMENT_WRITE_KEY=<YOUR_SEGMENT_WRITE_KEY>

3. In medusa-config.js add the following at the end of the plugins array:

const plugins = [
  // ...
  {
    resolve: `medusa-plugin-segment`,
    options: {
      write_key: process.env.SEGMENT_WRITE_KEY,
    },
  },
]

Test the Plugin

1. Run the following command in the directory of the Medusa backend to run the backend:

npm run start

2. Place an order using a storefront or the Store APIs. You should see the event tracked in Segment.


Additional Resources