---
url: https://simpledatalogs.com/docs/integrations/segment.md
description: >-
  Point Segment's server SDKs at simpledatalogs by changing the API host and
  using the ingest key as the write key.
---

# Segment

Segment's HTTP Tracking API is served as is. Change the SDK's host and use your ingest key as the write key; your `track`, `page` and `identify` calls stay the same.

::: code-group

```python [Python]
import segment.analytics as analytics

analytics.host = "https://edge.simpledatalogs.com"
analytics.write_key = "sdl_sec_…"

analytics.track("user-42", "order_completed", {"total": 29})
```

```js [Node]
import { Analytics } from '@segment/analytics-node'

const analytics = new Analytics({ writeKey: 'sdl_sec_…', host: 'https://edge.simpledatalogs.com' })

analytics.track({ userId: 'user-42', event: 'order_completed', properties: { total: 29 } })
```

```go [Go]
client, _ := analytics.NewWithConfig("sdl_sec_…", analytics.Config{
    Endpoint: "https://edge.simpledatalogs.com",
})
```

```ruby [Ruby]
analytics = Segment::Analytics.new(write_key: "sdl_sec_…", host: "edge.simpledatalogs.com")
```

```swift [Swift]
let configuration = Configuration(writeKey: "sdl_pub_…")
    .apiHost("edge.simpledatalogs.com/v1")
```

:::

| SDK | Status |
|---|---|
| Python (`segment-analytics-python` 2.x) | Tested (2.3.3) |
| Node (`@segment/analytics-node`) | Tested (2.1.2) |
| Go, Ruby, Swift, Kotlin | Written from their docs; not yet tested |
| Browser (analytics.js) | Not drop-in: it posts to Segment's short paths, which ingest doesn't serve. Use the [JavaScript SDK](/sdks/javascript) |

Segment SDKs send the write key as HTTP Basic auth, which ingest reads. Python 2.x sends it only inside the JSON body; on the Segment paths ingest reads it from there, as long as the body isn't gzipped.

## Paths

`POST /v1/batch`, `/v1/track`, `/v1/page`, `/v1/screen`, `/v1/identify`, `/v1/group` and `/v1/alias`, with `application/json` (or `text/plain` with a JSON body).

## How messages map

| Field | From the message |
|---|---|
| `event` | track: its `event`; page `page_view`; screen `screen_view`; identify `identify`; group `group`; alias `alias` |
| `user_id`, `anonymous_id` | `userId`, `anonymousId` |
| `event_id` | `messageId`, so a retried batch never counts twice |
| `ts` | `timestamp`, else `originalTimestamp` |
| `props` | `properties`, plus `name` and `category` (page, screen), `traits` (identify, group), `group_id`, `previous_id`, and `context` |

`writeKey`, `integrations`, `sentAt` and `context.ip` are never stored.

## Answers

Success is `200 {"success":true}`, sent only once the batch is stored. Errors use the [usual statuses](/api/responses#segment-paths) with Segment's error body.

## Next steps

* [Payload shapes](/integrations/payload-shapes): PostHog, Mixpanel and Amplitude events on `/v1/ingest`.
* [Core concepts](/guide/concepts#devices-and-identity): how `userId` and `anonymousId` count as devices.
