Segment Analytics
npm install medusa-plugin-segmentTrack essential commerce analytics with Segment.
Segment Plugin Documentation | Medusa Website | Medusa Repository
- Automatic analytics tracking for events related to Orders, Swaps, and Claims.
- Flexibility to track analytics for custom events or operations.
---
- Medusa backend
- Segment account
---
1\. Run the following command in the directory of the Medusa backend:
``bash`
npm install medusa-plugin-segment
2\. Set the following environment variable in .env:
`bash`
SEGMENT_WRITE_KEY=
3\. In medusa-config.js add the following at the end of the plugins array:
`jsmedusa-plugin-segment
const plugins = [
// ...
{
resolve: ,`
options: {
write_key: process.env.SEGMENT_WRITE_KEY,
},
},
]
---
1\. Run the following command in the directory of the Medusa backend to run the backend:
`bash``
npm run start
2\. Place an order using a storefront or the Store APIs. You should see the event tracked in Segment.
---