Overview
Icon for Segment

Segment

Track and unify customer data with Segment

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 Copy to clipboard.env:

SEGMENT_WRITE_KEY=<YOUR_SEGMENT_WRITE_KEY>

3. In Copy to clipboardmedusa-config.js add the following at the end of the Copy to clipboardplugins 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

You may also like

Browse all integrations

Build your own

Develop your own custom integraiton

Build your own integration with our API to speed up your processes. Make your integration available via npm for it to be shared in our Library with the broader Medusa community.

gift card interface

Ready to build your custom commerce setup?