Send data from Segment to Monita
Segment can forward the events in your workspace to Monita using a webhook destination, or a Destination Function if you want full control of the payload shape.
Before you start
Section titled “Before you start”- A Segment source receiving events.
- Your Monita property token and vendor names — see the Monita-side setup.
Option A — Destination Function (recommended)
Section titled “Option A — Destination Function (recommended)”A Destination Function lets you map Segment’s event shape onto Monita’s exactly:
-
In Segment, go to Connections → Catalog → Functions → New Function → Destination.
-
Use a handler like:
async function onTrack(event, settings) {await fetch('https://collect.monita.ai/api/v1/', {method: 'POST',headers: {token: settings.monitaToken,'Content-Type': 'application/json',},body: JSON.stringify({s: 'global',dm: 'tms',e: event.event,vn: 'Segment',u: event.context?.page?.url,do: 'www.your-domain.com',sid: event.anonymousId,cid: event.userId,dt: [{ event: event.event, ...event.properties }],}),});} -
Add a
monitaTokensetting, connect the function to your source, and enable it.
Option B — Webhook destination
Section titled “Option B — Webhook destination”The catalog Webhooks destination can POST to https://collect.monita.ai/api/v1/ with the token header set. Segment will send its own event envelope rather than Monita’s field names — Monita accepts the JSON, but events group best when you use a Destination Function to map e, vn and dt properly.
Verify
Section titled “Verify”- Check the function’s event delivery log for
204responses (401= wrong or missing token). - In Monita, events appear in the property’s Visualisation view within a minute or two.