> For the complete documentation index, see [llms.txt](https://docs.chord.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chord.co/get-started/implementation-guide/migrating-from-segment-to-chord-cdp.md).

# Migrating from Segment to Chord CDP

{% hint style="info" %}
The only difference between using Chord's SDKs to send events to Chord CDP vs Segment is *where the events are sent*. **The events will remain exactly the same.** As a result, only small configuration changes are needed. Easy!
{% endhint %}

## Client-side / front-end events

### Chord Analytics library

If you're using the `@chordcommerce/analytics` library on a headless site, your current implementation might look something like this:

```javascript
import { ChordAnalytics } from '@chordcommerce/analytics'
import { AnalyticsBrowser } from '@segment/analytics-next'

const cdp = AnalyticsBrowser.load({
  writeKey: process.env.SEGMENT_WRITE_KEY,
})
const chord = new ChordAnalytics({
  cdp,
  formatters: { ... },
  metadata: { ... },
})

// Example events
chord.page()
chord.trackProductAdded({ ... })
```

In that case, migrating to Chord CDP will involve:

1. updating `@chordcommerce/analytics` to version `1.9.1` or greater
2. removing the `@segment/analytics-next` dependency
3. removing initialization of the `cdp` variable and configuration option
4. using `cdpDomain` and `cdpWriteKey` configuration options - both to be provided by Chord - instead
5. using the `consent` configuration option for built-in consent management support (optional)

The resulting code will look something like this:

```javascript
import { ChordAnalytics } from '@chordcommerce/analytics'

const chord = new ChordAnalytics({
  cdpDomain: process.env.CHORD_CDP_DOMAIN,
  cdpWriteKey: process.env.CHORD_CDP_WRITE_KEY,
  consent: 'shopify', // optional
  formatters: { ... },
  metadata: { ... },
})

// Example events (unchanged)
chord.page()
chord.trackProductAdded({ ... })
```

**Running both in parallel**

It is possible to send every event to both Chord CDP *and* Segment at the same time. This is useful for running a side-by-side comparison of event data during migration. It also buys more time when migrating destinations.

The resulting code would be a combination of the two examples above; for example:

```javascript
import { ChordAnalytics } from '@chordcommerce/analytics'
import { AnalyticsBrowser } from '@segment/analytics-next'

const cdp = AnalyticsBrowser.load({
  writeKey: process.env.SEGMENT_WRITE_KEY,
})
const chord = new ChordAnalytics({
  cdp,
  cdpDomain: process.env.CHORD_CDP_DOMAIN,
  cdpWriteKey: process.env.CHORD_CDP_WRITE_KEY,
  formatters: { ... },
  metadata: { ... },
})

// Example events (unchanged)
chord.page()
chord.trackProductAdded({ ... })
```

Once the validation and migration are complete, the Segment code can be safely removed to match the second example.

### Shopify web pixel

If you're using Chord's Shopify web pixel - either for a fully Liquid site or just for Checkout Extensibility - we will provide an updated web pixel that supports Chord CDP.

### Chord OMS SDKs

If your storefront is built on Chord OMS using the Gatsby or Next.js starterkits, the Chord team will help you swap the Segment snippet for the Chord CDP snippet.

## Server-side / back-end events

Regardless of OMS, Chord will assist in the migration of server-side/back-end events. It will be an equally simple process, but the actual implementation will vary based on the current architecture.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chord.co/get-started/implementation-guide/migrating-from-segment-to-chord-cdp.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
