Segment

📘

This integration is currently in beta. Contact your MetaRouter support team to get started.

What Is Segment?

Segment is a customer data platform (CDP) that collects behavioral event data from websites, mobile apps, and servers and routes it to downstream destinations for analytics, marketing, advertising, and data warehousing. It standardizes event collection around a common specification of Identify, Track, Page, Screen, Group, and Alias calls, so a single stream of customer data can feed many tools without separate instrumentation for each. The Segment HTTP Tracking API accepts analytics data from any website or application, and Segment then routes that data to the destinations configured in the workspace.


Product Type: Customer Data Platform
Integration Type: Starter Kit
Event Source Type: Web, Mobile Browser, and Mobile App
Event Scope: Full-Funnel Events


Capabilities

  • Sends Identify, Page, Screen, and Track events to Segment's HTTP Tracking API from the server side, without a client-side Segment tag.
  • Forwards common context fields (page, campaign, device, app, OS, locale, IP, and user agent) when provided.
  • Sends anonymousId and userId with every event so Segment can associate activity with a user.
  • Delivers events in batches to Segment's batch endpoint, reducing the number of outbound requests.
  • Lets one event stream feed every downstream destination connected to the Segment source.

Considerations

  • Events are authenticated with the Write Key from your Segment HTTP API source and land in the source that key belongs to.
  • Events go to Segment's Oregon region by default. To send to Dublin (Regional Segment, Business plans), set HOST to events.eu1.segmentapis.com.
  • Every event needs a userId, an anonymousId, or both. Events with neither are rejected.
  • Every event needs a valid type (identify, page, screen, or track), and every Track event needs an event name.
  • properties accepts any fields, but revenue, currency, and value are reserved by Segment and should only be used for their intended purpose.
  • Timestamps must be ISO-8601 in UTC. Include timestamp when sending historical events.
  • Segment removes duplicate events using messageId, which must be unique and under 100 characters.
  • Size limits are 32 KB per event, and 500 KB or 2,500 events per batch. This integration sends up to 100 events per batch.
  • Oversized or invalid payloads return a 400 error.
  • IP addresses are sent as IPv4 only.
  • Segment recommends staying under 1,000 requests per second per workspace.
  • Events reaching Segment does not mean they reach downstream destinations. Confirm each destination accepts server-side data and is set up correctly.

Limitations

  • A 200 response from Segment does not guarantee that the batch, or the events within it, were accepted. Always verify delivery in the Segment Debugger.
  • Group and Alias calls are not supported by this starter kit.
  • Device-mode (client-side) destination features available through Segment's native libraries are not available, since events are delivered server-side.

Starter Kit Setup Guide

1. Gather Credentials

  • Source Write Key: In your Segment workspace, go to Connections, then Sources, and click Add Source. Search for and add the HTTP API source, then open the source's Settings tab, select API Keys, and copy the Write Key.
  • Workspace Region: Confirm whether your Segment workspace processes data in the US (Oregon) or EU (Dublin) region. This integration defaults to Oregon.

2. Add a Segment Integration

  • From the integration library, add a Segment integration. Then, fill out the Connection Parameters:
Connection ParameterDescription
WRITEKEYSegment HTTP API source Write Key, used to generate the HTTP Basic Auth header.
HOSTSegment API host. Defaults to api.segment.io (Oregon). Use events.eu1.segmentapis.com for Dublin.

3. Configure Event Mapping

  • MetaRouter provides all of the event mappings that Segment integrations typically require. You may add custom events, parameters, or mappings in accordance with Segment's API documentation.

4. Deploy to Pipeline

  • In the Pipelines tab, add your Segment integration.
  • Select the correct integration revision.
  • Click Add Integration and finalize deployment.

Event Mappings

Global

Global mappings will be applied to all events. If your parameter names do not match the Expected Inputs provided, you will need to overwrite the Inputs provided with your own.

Output KeyDescriptionExpected Input
type RequiredString: Event method name; must be identify, page, screen, or track on every batch item.type
messageIdString: Unique event identifier used by Segment for deduplication; keep under 100 characters.messageId
anonymousId RequiredString: Anonymous user identifier; one of anonymousId or userId must be present.anonymousId
userId RequiredString: Known user identifier; one of anonymousId or userId must be present.userId
receivedAtString: Time the event was received, in ISO-8601 format and UTC.receivedAt
timestampString: Time the event occurred, in ISO-8601 format and UTC.timestamp
sentAtString: Time the event was sent, in ISO-8601 format and UTC.sentAt
context.libraryObject: Name and version of the library that collected the event.context.library
context.ipString: IPv4 address of the user.context.ip
context.localeString: Locale of the user.context.locale
context.pageObject: Page details such as path, referrer, search, title, and URL.context.page
context.userAgentString: User agent of the browser or device.context.userAgent
context.traitsObject: User traits attached to the event context.traits
context.appObject: App details such as name, version, and build.context.app
context.campaignObject: Campaign details such as name, source, medium, term, and content.context.campaign
context.deviceObject: Device details such as ID, advertising ID, type, manufacturer, and model.context.device
context.networkObject: Network details such as carrier and connection type.context.network
context.osObject: Operating system name and version.context.os
context.screenObject: Screen dimensions and density.context.screen
context.timezoneString: Timezone of the user.context.timezone
context.groupIdString: Group or account identifier associated with the user.context.groupId
context.userAgentDataObject: Structured user agent client hints.context.userAgentData

Event Specific

Identify

Output KeyDescriptionExpected Input
traitsObject: Free-form user traits, such as email or name.traits

Page

Output KeyDescriptionExpected Input
nameString: Name of the page.properties.name
propertiesObject: Free-form page properties, such as path, title, url, and referrer.properties

Screen

Output KeyDescriptionExpected Input
nameString: Name of the app screen.properties.name
propertiesObject: Free-form screen properties.properties

Products Searched

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Products Searched'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Product List Viewed

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Product List Viewed'
propertiesObject: Free-form Track event properties, including the products array.properties

Product Clicked

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Product Clicked'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Product Viewed

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Product Viewed'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Product Added

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Product Added'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Product Removed

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Product Removed'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Product Added To Wishlist

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Product Added To Wishlist'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Cart Viewed

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Cart Viewed'
propertiesObject: Free-form Track event properties, including cart_id and the products array.properties

Checkout Started

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Checkout Started'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Coupon Entered

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Coupon Entered'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Payment Info Entered

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Payment Info Entered'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Promotion Viewed

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Promotion Viewed'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Promotion Clicked

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Promotion Clicked'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Order Completed

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Order Completed'
propertiesObject: Free-form order properties (order ID, revenue, tax, shipping, discount, coupon, products); revenue is reserved.properties

Order Updated

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Order Updated'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Order Canceled

Output KeyDescriptionExpected Input
event RequiredString: Track event name, sent to Segment as Order Cancelled.Enrichment – 'Order Cancelled'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Order Refunded

Output KeyDescriptionExpected Input
event RequiredString: Track event name.Enrichment – 'Order Refunded'
propertiesObject: Free-form Track event properties; reserved names keep their Segment meaning.properties

Required & Recommended Identifiers

These identifiers must be mapped to Segment in order for successful user matching to occur. Without these IDs, any events sent to Segment may not be accurately reflected in reporting.

AttributeExampleSync Injector Required?
anonymousId Requiredce576487-95f9-4262-9315-2c7942b061c8No
userId Required019mr8mf4rNo
messageId Recommended022bb90c-bbac-11e4-8dfc-aa07a5b093dbNo
traits.email[email protected]No
context.ip24.5.68.47No
context.userAgentMozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36No
context.device.advertisingId38400000-8cf0-11bd-b23e-10b96e40000dNo

Integration Validation

Use the Debugger tab on your Segment HTTP API source to confirm events are arriving. The Debugger shows each incoming event with its type, name, and full payload, so you can check that identifiers, properties, and context fields are mapped as expected. Because Segment can return a 200 response even when events are rejected, the Debugger is the most reliable way to confirm events were accepted.

To confirm events are reaching your connected destinations, open each destination in Segment and review its Event Delivery dashboard, which shows delivered events and any failures by error type.


Additional Segment Documentation